Macromedia Dreamweaver 8: Training from the Source

HTML distinguishes a single standard spacemultiple spaces are not recognized. A special character called a nonbreaking space can be used when you need to create a space between two words that should not be split as a result of a text wrap. A nonbreaking space will prevent a line break from occurring at the point where it is insertedthe content before and after the special space will be constrained to the same line. The location where the line break happens in a block of text as a result of text wrap on a Web page can vary greatly depending on many factors, including font size and the size of the visitor's browser window. Using a regular space between "Yoga" and "Sangha," for instance, might result in the word "Yoga" appearing at the end of a line and the word "Sangha" appearing at the beginning of the next line. Using the nonbreaking space would force the browser to keep these two words together.

The nonbreaking space has been used to create the effect of multiple spaces because you can insert more than one space consecutively. You can also insert nonbreaking spaces at the beginning of a line of text, whereas you can't begin a line with a standard space. However, it is best to use other methods to control the layout such as creating first line indents with CSS. Nonbreaking spaces are best used any time you need to insert a space between characters, words, or other elements that should not be separated, such as mathematical equations, names and their suffixes, and dates.

1.

In the index.html document, position the insertion point between the words Anusara and Yoga at the end of the first line below the Discover how playful and open-hearted yoga can be header.

If you press the spacebar more than once, there is no change in the amount of space between the words, and only a single space remains. Multiple spaces are not recognized.

2.

Delete the existing space, and then press Option+Spacebar (Macintosh) or Crtl+Shift+Spacebar (Windows) once.

Tip

You can also insert a nonbreaking space by choosing Insert > HTML > Special Characters > Non-Breaking Space or by selecting the Text category in the Insert bar, clicking the Characters menu, and selecting Non-Breaking Space.

The spacing between the words will increase each time you insert a nonbreaking space.

Note

You can allow for multiple spaces when you type by changing the preferences. Choose Dreamweaver > Preferences (Macintosh) or Edit > Preferences (Windows) and select the General category. Check the box next to Allow Multiple Consecutive Spaces. With this option enabled, Dreamweaver uses nonbreaking spaces whenever you hit the Spacebar more than once. Use this option with care because CSS is a better method of controlling spacing and layout.

3.

Preview index.html in a browser. Expand and reduce the size of the browser window to make the line break occur where the split between the words Anusara and Yoga would appear.

Notice how the words are kept to the same linethe break occurs either before or after, but not where the nonbreaking space is located.

Note

Previewing Dreamweaver documents in browsers was covered in Lesson 1.

Категории