News:

This week IPhone 15 Pro winner is karn
You can be too a winner! Become the top poster of the week and win valuable prizes.  More details are You are not allowed to view links. Register or Login 

Main Menu

HTML course - The <BR> (break) Tag

Started by ben2ong2, October 03, 2006, 05:46:49 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

ben2ong2

Let's try out an experiment. Open Notepad and type in the following code exactly as I have written. Check the results in a browser.

<HTML>
<HEAD>
<TITLE>Testing the BR tag</TITLE>
</HEAD>
<BODY>
This is a long piece of text consisting of three
sentences and shows you the functions of the
Line Break tag. This tag is used quite frequently
to add line breaks in the HTML code. It is also used
to add blank lines to a document.
</BODY>
</HTML>

The text is placed on five lines. When you display the file in a browser, you shall find that the line breaks we had introduced (by hitting 'Enter' key) are ignored by the browser.
The browser 'wraps' the text only at the end of the window space. In the browser window, click on VIEW - SOURCE (or PAGE SOURCE in Netscape). The line breaks are still very much present! So what is happening? Try hitting the 'Enter' key 10 times after the first line, the browser will ignore all these. This is because HTML has a special Line Break Tag, <BR>. You should use this tag to introduce any line breaks.

<HTML>
<HEAD>
<TITLE>Testing the BR tag</TITLE>
</HEAD>
<BODY>
This is a long piece of text consisting of three<BR>
sentences and shows you the functions of the<BR>
Line Break tag. This tag is used quite frequently<BR>
to add line breaks in the HTML code. It is also used<BR>
to add blank lines to a document.<BR>
</BODY>
</HTML>
When the above code is displayed in a browser, the text will be broken into five lines.

The <BR> tag has no end tag because it doesn't need too. Just the presence of <BR> adds a line break.

The opposite of the <BR> tag is the <NOBR> tag. It has an ending </NOBR> tag. Text placed between these tags will be displayed in a single line, which might result in horizontal scrolling if the text too is long. Try this out with the following code.

<HTML>
<HEAD>
<TITLE>Testing the BR tag</TITLE>
</HEAD>
<BODY>
<NOBR>
This is a long piece of text consisting of three
sentences and shows you the functions of the
NOBR tag. This tag is causes the text between it
to be displayed in a single line and will result
in horizontal scrolling in the browser if the text
is too long and continues and continues and continues
and continues and continues and continues and continues
and continues and continues and continues and continues
and continues and continues and continues and continues
and continues and continues and continues and continues
and continues and continues and continues and continues
and continues and continues and continues and continues
and continues and continues and continues and continues
and finally ends here.
</NOBR>
</BODY>
</HTML>

You are not allowed to view links. Register or Login
You are not allowed to view links. Register or Login