Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Web Design & Development > Usability

  • Print
  • + Share This
This chapter is from the book

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 66), 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.

Example 3.18. 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 of space between each one.


<div id="toc">Antoni Gaudí<br />La Casa
Milà<br />La Sagrada Família</div>

<div id="gaudi">

<h1>Antoni Gaudí</h1>

<p>Many tourists are drawn to Barcelona to see
Antoni Gaudí's incredible architecture. </p>

<p>Barcelona celebrates the 150th anniversary of
Gaudí's birth in 2002.</p>

<div class="works">

<h2>La Casa Milà</h2>

<p>Gaudí's work was essentially useful. La Casa
Milà is an apartment building and <span
class="emph">real people</span> live there.</p>

Example 3.19. Remember that the returns in your code are always ignored. This code is equivalent to that shown above in Figure 3.18.

<div id="toc">Antoni Gaudí
<br />La Casa Milà
<br />La Sagrada Família</div>

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

  • + Share This
  • 🔖 Save To Your Account