C & G web

Paragraph and Break

The P tag is used to indicate paragraphs. The optional attribute ALIGN indicates the preferred alignment for the contents of this paragraph. Support for ALIGN=RIGHT is not as large as support for the other two. Note that ALIGN=LEFT is the default.

Notes:

  • Some browsers render extra whitespace when multiple empty paragraphs are used in sequence. This is not required by the specs, so do not count on this to get vertical whitespace in your document.
  • When a paragraph has the ALIGN=CENTER or ALIGN=RIGHT attribute, some browsers do not use the default alignment for the next paragraph unless this paragraph is explicitly closed.
  • In the very first version of HTML, the P tag was an empty tag like BR. Some references and books still claim that this is the case. However, HTML 2.0 defines the P tag as a container, and there is no difference between a paragraph with and one without explicit alignment.
  • Despite the above, some browsers treat the closing tag as an opening tag - they insert an extra paragraph break there.

The BR tag is used to force line breaks within text. Normally, linebreaks are treated as a space by browsers (except inside the PRE tag). The optional CLEAR attribute is used when you have an IMG image in your text. If that image uses ALIGN=LEFT or ALIGN=RIGHT, the text will flow around it. If you have text you want below the image, you can do this with <BR CLEAR=LEFT> or CLEAR=RIGHT to force scrolling down to a clear left or right margin, respectively. Using CLEAR=ALL will scroll down until both margins are clear. CLEAR=NONE is the default, and does nothing.

Notes:

Some people use multiple BR tags to force whitespace. This is not required by the specs, so it may not work in all browsers.

Example - Paragraph and Break

The document content goes here
To start a new line a break ' br ' tag is required
This tag is different in that there is no closing tag.
In fact the use of the closing tag is forbidden.

To start a new paragraph a ' p ' tag is required.
The paragraph tag also does not require a closing tag.

Although it may be used and is optional.

The tag should never be empty i.e. with no content between it and the next ' p ' tag!

Even though in the above code there were sixteen opening ' p ' tags and three closing
the browser ignored them, as there was only 'White Space' between.

The HTML

<html>
<head>
	<title>Paragraph and Break</title>
</head>

<body>

The document content goes here<br>
		
To start a new line a break ' br ' tag is required<br>
		
This tag is different in that there is no closing tag.<br>
		
In fact the use of the closing tag is forbidden. 
		
<p>To start a new paragraph a ' p ' tag is required.<br>
		
The paragraph tag also does not require a closing tag.
		
<p>Although it may be used and is optional.</p>
		
<p> <p>
		
		
<p> <p> <p> <p>
		 
<p></p>			<p> <p> <p></p> <p> <p> <p>

<p></p> <p> <p>
		
The tag should never be empty i.e. with no content between it and the next ' p ' tag!
		
<p>Even though in the above code there were sixteen opening ' p ' tags and three
closing the browser ignored them, as there was only 'White Space' between.

</body>
</html>
		

Previous page...

Back to Top of Page

Computeach International Ltd

Christopher Ward London Limited

Christopher Ward London Limited