Translate

ads

6 Jun 2019

HTML | Paragraph


HTML | Paragraph



The tag in hypertext mark-up language defines a paragraph. These have each gap and shutting tag. thus something mentioned inside and is treated as a paragraph. Most browsers browse a line as a paragraph notwithstanding we have a tendency to don’t use the closing tag




<!DOCTYPE html> 
<html> 
<head> 
 <title>Paragraph</title> 
</head> 
<body> 
 <p>This is paragraph.</p> 
 <p> This is paragraph.</p> 
</body> 
</html> 

Output:


When we check up on the webpage, we tend to see that there area unit few areas supplementary before and once a paragraph. HTML will this by default. Let’s check up on few properties of paragraph tag:


ü  As already mentioned, the tag mechanically adds house before and when any paragraph, that is largely margins other by the browser.
ü  If a user adds multiple areas, the browser reduces them it to one house.
ü  If a user adds multiple lines, the browser reduces them to one line


<!DOCTYPE html> 
<html> 
<head> 
 <title>Display Paragraph</title> 
</head> 
<body> 
 <p> 
 This paragraph has multiple 
 lines. But HTML reduces them 
 to a single line, omitting 
 the carriage return we have used. 
 </p> 

 <p> 
 This paragraph  has multiple 
 spaces.  But HTML reduces them 
 all to a  single space, omitting 
 the extra spaces and line we have used. 
 </p> 
</body> 
</html> 

Output:

align Attribute: The <p> tag specifically supports the alignment attribute and allows us to align our paragraphs in left, right or center alignment.

Syntax:

<p align="value">




<!DOCTYPE html> 
<html> 
<head> 
 <title>Paragraph</title> 
</head> 
<body> 
 <p align="center">Welcome to sayed 360</p> 
 <p align="left">A blog portal site.</p> 
 <p align="right">It contains well written, well thought articles.</p> 
</body> 

</html> 

Output:


The <pre> element

We have seen how the paragraph tag ignores all the change of lines and extra spaces within a paragraph, but there is a way to preserve this by the use of <pre> tag. It also contains an opening and a closing tag. It displays a text within a fixed height and width and preserves the extra lines and spaces we use.

<!DOCTYPE html> 
<html> 
<head> 
 <title>Display Paragraph</title> 
</head> 
<body> 
 <pre> 
 This paragraph has multiple 
 lines. But it is displayed 
 as it is unlike the paragraph 
 tag. 
 </pre> 

 <pre> 
 This  paragraph has multiple 
 spaces. But  it is displayed 
 as it is unlike the paragraph 
  tag. 
 </pre> 
</body> 

</html> 

Output:




No comments:

Post a Comment