Maddog's HTML for Real People Chapter 2, Lesson 7


[INDEX] Ch 2, L 7 - Adding Spaces

If you already know how to add a non-blanking space to an HTML document, you can skip this lesson.

One of the things that drove me NUTS about HTML when I first started building web pages was that I couldn't figure out a way to get more than one space in a row. After all, remember, HTML ignores all whitespace and converts it to ONE space. Let's say you want to put two (2) spaces in front of a new sentence. Now, as any secretary can tell you, that is the only way to type a document. [as you may have noticed, I'm not a secretary...]. For a long time, I thought it was impossible with HTML. We'll cover HTML special characters in later chapters, but for now I want you to know about this one in particular, so you wan't end up with a nervous breakdown over this issue, like I did.

If you want to force a space in HTML, use the Non-Breaking-SPace special character, which is:

 

Don't forget the semicolon; it's required. For each " " you type, you'll get one "space", right in the text where you typed it. [as a result, I'm finally off the tranquilizers...]

Let's see an example:

HTML Source Code Follows:


     The quick brown fox jumps over the lazy dog.  
  The quick brown fox jumps over the lazy dog.
  The quick brown fox jumps over the lazy dog.
  The quick brown fox jumps over the lazy dog.
  The quick brown fox is getting on my nerves.

(End of HTML Source Code)

Demonstration Follows:

     The quick brown fox jumps over the lazy dog.   The quick brown fox jumps over the lazy dog.   The quick brown fox jumps over the lazy dog.   The quick brown fox jumps over the lazy dog.   The quick brown fox is getting on my nerves.

(Demonstartion Ends)

Check out the features we've demonstrated. By inserting five (5)   tags at the beginning of our paragraph, we were able to force the browser to indent 5 spaces. Then, to satisfy the retentive secretary, we inserted two (2)   tags at the beginning of each sentence, forcing the browser to put 2 spaces before each new sentence. Notice, we get one explicit "space" for each instance of   tag that we insert.

A word of caution about using   special character: Don't get too "caught up" in using them. First, because it makes your source text file less readable. Second, it makes your HTML file larger. For each "space" you insert, six (6) characters are required (count' em). If you were to use them indiscriminately, you could use significantly more disk space, waste internet bandwidth and make your web page take longer to load at the receiving browser. [Some Text- to-HTML Conversion software, and some commercial HTML editors, use the   special character to guarantee that the page looks like you think it's going to look, and they can use thousands of these byte-wa sters.]

A further warning: be aware that not all browsers support the   special character. Most recent browsers do. However an earlier browser may print ' ' instead of the space, or ignore it altogether. If you use it very much, your page could look quite unlike what you expected when viewed on an older browser.


-PREVIOUS- -CHAPTER- -INDEX- -NEXT-

Overseer: Monty Northrup ... maddog@io.com ... leave e-mail ...
...to maddog 'n' miracles homepage...