Line Break


The <br> tag breaks a line of text at the point where it appears. When a web browser encounters a <br> tag, it restarts the text after the tag at the left margin (whatever the current left margin happens to be for the current element). You can use <br> within other elements, such as paragraphs or list items; <br> won't add extra space above or below the new line or change the font or style of the current entity. All it does is restart the text at the next line.

Closing Single Tags Properly

Like the <hr> tag, the <br> tag has no closing tag in HTML. To convert this tag to XHTML and to ensure compatibility with HTML browsers, add a space and forward slash to the end of the tag and its attributes, as shown in the following example:

And then is heard no more: it is a tale <br /> Told by an idiot, full of sound and fury, <br /> Signifying nothing.</p>



The following example shows a simple paragraph in which each line (except for the last, which ends with a closing <p> tag) ends with a <br>:

Input

<p>Tomorrow, and tomorrow, and tomorrow,<br /> Creeps in this petty pace from day to day,<br /> To the last syllable of recorded time;<br /> And all our yesterdays have lighted fools<br /> The way to dusty death. Out, out, brief candle!<br /> Life's but a walking shadow; a poor player,<br /> That struts and frets his hour upon the stage,<br /> And then is heard no more: it is a tale <br /> Told by an idiot, full of sound and fury, <br /> Signifying nothing.</p>


Figure 6.10 shows how it appears in a browser.

Note

clear is an attribute of the <br> tag. It's used with images that have text wrapped alongside them. You'll learn about this attribute in Lesson 7, "Adding Images, Color, and Backgrounds."


Output

Figure 6.10. Line breaks.





Sams Teach Yourself Web Publishing with HTML and CSS in One Hour a Day
Sams Teach Yourself Web Publishing with HTML and CSS in One Hour a Day (5th Edition)
ISBN: 0672328860
EAN: 2147483647
Year: 2007
Pages: 305

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net