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


[INDEX] Ch 2, L 8 - Preventing Line Breaks

If you already know how to prevent line breaks and word-wrapping in HTML, you can skip this lesson.

Sometimes you want to make sure that the browser WON'T create a line break. For example, you may want to create a textual table in which the first letter of each line forms a word, or anagram, vertically. [Clever little tyke, ain't you?]. Well, since you can't be sure of where the line breaks will be inserted by the receiving browser, you need a way of preventing them, The HTML tag pair <NOBR> </NOBR> will accomplish this for you. When you get to the text table in your HTML document, insert <NOBR> which means (to the browser) "don't word-wrap". Then when that text table is finished, insert </NOBR> which means "OK, word wrap again".

Let's see an example:

HTML Source Code Follows:



&nbsp;&nbsp;The quick brown fox jumps over the lazy dog.  
&nbsp;&nbsp;The quick brown fox jumps over the lazy dog.
&nbsp;&nbsp;The quick brown fox jumps over the lazy dog.
&nbsp;&nbsp;The quick brown fox jumps over the lazy dog.
&nbsp;&nbsp;The quick brown fox is getting on my nerves.
<P>
<NOBR>
"A" is for Apple; 
you the apple of my eye, which I have to let you know, really hurts sometimes, 
because, well, you know, it's just the way it is, because I cant quite explain it 
but I'm telling the truth, really I am;<BR>
"B" is for Boy oh boy, 
I'll probably get the Pulitzer prize for my oh-so-astounding
 writing talents; which of course is no news to you because you've never 
ceased to be enthralled by all of this<BR>
"C" is for Courage; 
because that's what it takes to make a 
fool out of yourself by writing drivel like this for all the 
world to see.<BR>
</NOBR>

(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.

"A" is for Apple; you the apple of my eye, which I have to let you know, really hurts sometimes, because, well, you know, it's just the way it is, because I cant quite explain it but I'm telling the truth, really I am;
"B" is for Boy oh boy, I'll probably get the Pulitzer prize for my oh-so-astounding writing talents; which of course is no news to you because you've never ceased to be enthralled by all of this
"C" is for Courage; because that's what it takes to make a fool out of yourself by writing drivel like this for all the world to see.

(Demonstartion Ends)

In the first paragraph, the web browser automatically removed whitespace and word-wrapped (as we wanted it to). But then, we wanted to get oh-so-clever. We inserted a <NOBR> tag so as to turn off word wrapping. From that point on, until we used a </NOBR> closing tag, it was strictly up to us to tell the browser where to put the end-of-line breaks. This enabled us to form the remarkable vertical "ABC" formed by the beginning letter of each [looney] sentence.

Also, notice that no text is lost in the web page, you just have to use your browser's "window scroll" bar to see whatever is hidden out to the right.

Alas, the <NOBR> tag is not supported in all browsers, and if it didn't behave as I described, your browser doesn't support it. In fact, the <NOBR> tag is not an official HTML tag, but the most recent Netscape and Internet Explorer versions support it, and for some insane reason, I thought it should be included.

One of the tricky things about building web pages is that all web browsers do not behave the same. Although I can't predict what will happen with yours, especially if it is more than a year or two old, I'll do my best to let you know when browser compatibilty might be a problem. It will be up to you, the web page author, to weigh the pros and cons of using tags or features like <NOBR>; the "pro" will be the cool way it behaves on an advanced browser, and the "con" will be that you risk some fraction of your audience seeing something you didn't expect.


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

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