Creating a Line Break


Browsers automatically wrap text according to the width of the block or window, creating new lines as necessary. While you can start a new paragraph with the p tag (see page 62), you can also create manual line breaks anywhere you like.

The br tag is perfect for poems or other short lines of text that should appear one after another without a lot of space in between.

To insert a line break:

Type <br /> where the line break should occur. There is no separate closing br tag.

Figure 3.20. I've created a new division at the top of the page that can serve as a table of contents. There will be three lines (thanks to the br tag) with the minimum amount of space between each one.


Figure 3.21. Remember that the returns in your code are always ignored. This code is equivalent to that shown above in Figure 3.20 though it's easier to read.


Figure 3.22. The br element starts the subsequent elements on a new line.


Tips

  • The closing slash (/) is only required in XHTML documents to satisfy the rule that all elements be properly closed (see page 38). Make sure there is a space between br and the slash. You may omit the slash entirely in HTML documents, though it does no harm to include it.

  • You can use multiple br tags to create extra space between lines or paragraphs.

  • Styles can help you control the space between lines in a paragraph (see page 158) and between the paragraphs themselves (see pages 176177).

  • The br tag used to be used with the deprecated clear attribute to control text that is wrapped around images (see page 98). Its function has been replaced by the CSS clear property (see page 182).

  • The CSS white-space property is great for maintaining original page breaks (see page 164).





HTML, XHTML, & CSS(c) Visual QuickStart Guide
HTML, XHTML, and CSS, Sixth Edition
ISBN: 0321430840
EAN: 2147483647
Year: 2004
Pages: 340

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