Line break control


Non-Breaking Space

Dreamweaver Tip

Use "Ctrl-Shift-Spacebar" to create a hard-coded space ( ).

A non-breaking space can be added to text using one of the following codes:

  1. non-breaking space code
    ( )
  2. a noWrap code
    (<span class="noWrap"></span> /
    <span class="nowrap"></span>)
  3. a wrap-none code
    (<span class="wrap-none"></span>)

Deprecated Code in HTML5

Do not use the <nobr> tag as it is a non-conforming feature. (HTML5 (W3C))

The <nowrap></nowrap> attribute on the <td> and <th> tag is obsolete. (HTML5 (W3C))

Use the non-breaking space to do the following:

  • prevent content from splitting over multiple lines, which reduces readability
  • ensure that items (such as dates, names, numbers, percentages, some hyphenated words, certain phrases, etc.) do not become separated at the end of a line
  • keep the last two words of a paragraph together to prevent a single word from appearing by itself on a line
  • keep words at the beginning of a parentheses together with the rest of the text (e.g.&nbsp;text).

Examples

Below is a partial list of where to use the non-breaking space codes.

Addresses:
<span class="wrap-none">235 Queen Street</span>
<span class="wrap-none">Jean Edmonds Building</span>
North&nbsp;Tower

URLs and email addresses:
<span class="noWrap">www.ic.gc.ca</span>

Numbers and words:
page&nbsp;4
Table&nbsp;3
32&nbsp;MB
Figure&nbsp;3

Names:
Dr.&nbsp;Martin&nbsp;Labelle
<span class="nowrap">Prime Minister Harper</span>
<span class="nowrap">His Excellency the Right Honourable</span> David&nbsp;Johnston, <span class="nowrap">Governor General of Canada</span>

Dates:
October&nbsp;2,&nbsp;2013
le&nbsp;2&nbsp;octobre&nbsp;2013

Temperature:
14°&nbsp;Celcius

Percentages:
25&nbsp;percent
25&nbsp;p.&nbsp;100

Currency:
$5&nbsp;million
5&nbsp;000&nbsp;000&nbsp;$

French characters:
renseignements&nbsp;:
«&nbsp;mot&nbsp;»

Parentheses:
(e.g.,&nbsp;Use a non-breaking space to avoid breaking up text within a parentheses)

Non-Breaking Hyphen

The code for non‑breaking hyphen is &#8209;. This code is useful for keeping items such as hyphenated words (e.g., those words with short prefixes like "e-" or "co-") and telephone numbers together on a line.

Example

Code:

e&#8209;commerce
1&#8209;800&#8209;555&#8209;1111

Result:

e‑commerce
1‑800‑555‑1111

Adding Line Breaks

Break (<br>) Tag

Use the <br> Tag

Although both the <br /> and the <br> tags are acceptable in HTML5, use the <br> code from now on.

Dreamweaver CS5.5 will automatically insert the break code as <br> if you have the preferences set to HTML5 coding.

The <br> tag inserts a single line break. This tag is useful for adding a line break when including addresses, etc.

Do not use multiple <br> tags (e.g. <br><br>) to:

  • separate paragraphs—use the <p></p> tags instead; or
  • add spaces between items in an unordered or ordered list—use <ul class="space"> or <ol class="space"> instead.

Line Break Opportunity (<wbr>) Tag

The <wbr> tag does not necessarily add a line break, it just specifies a line break opportunity where a line break can occur if one is required.

This tag can be used for very long words or for long strings of text with no spaces (such as long URLs) where you would like to control where the line break will occur. Without the <wbr> tag, the word would either wrap at a strange place (making it difficult to read) or not wrap at all (thereby creating a large white space at the end of the line or pushing all the content to the next row).

The difference between the <wbr> tag and the <br> tag is that the <br> tag forces a line break. The <wbr> tag only adds a line break if one is necessary.

Example

Code:

The Industry Canada <cite>Report on Plans and Priorities</cite> can be found at <a href="http://www.tbs-sct.gc.ca/rpp/2012-2013/index-eng.asp?acr=1970">http://www.tbs-sct.gc.ca/rpp/<wbr>2012-2013/index-eng.asp?acr=1970</a>

Result:

The Industry Canada Report on Plans and Priorities can be found at http://www.tbs-sct.gc.ca/rpp/2012-2013/index-eng.asp?acr=1970

Note:

If no line break was indicated, the following line break would occur:

The Industry Canada Report on Plans and Priorities can be found at http://www.tbs-sct.gc.ca/rpp/2012-2013/index-eng.asp?acr=1970

Rate this page

The content of this page was useful to me.

Share this page

To share this page, just select the social network of your choice:
  • More

No endorsement of any products or services is expressed or implied.