Thursday, 21 June 2012

How to add a Line Break in Web Pages

The BR tag is used when you don’t want a full paragraph break. The space between lines of text is then reduced. The BR tag doesn’t need a closing tag, and can be just by itself.

As an example, add the following to the end of your text (the BR part).


<P>To die: to sleep; no more; and by a sleep to say we end the heart-ache and the thousand natural shocks that flesh is heir to, 'tis a consummation devoutly to be wish'd.

 

<BR>
... Rest of Hamlet's Soliloquy goes here

</BODY>
</HTML>


Notice that we've deleted the end P tag for the second paragraph. If you leave it in, you'll get a double line break from the two <P> tags, as well as a single line break from the <BR> tag.

 

Save your changes and switch to your browser. Press F5 to refresh the page and the results should look like this:

Web page showing the result of add BR Break tags

So if you don’t want a full, double-line break then remember to use the BR tag. And careful of the end P tags or you’ll end up more line breaks than you expected.

No comments:

Post a Comment