Line breaks and spaces
By default it doesn't matter how your text appears in your text editor. Internet
explorer will ignore all line breaks and extra spaces. If you want line
breaks you will need to include a tag for it.
For example if you were to type the following into your notepad file.
<body>
I
Love
HTML.
</body>
|
The result would be:
I Love HTML.
This is because the browser will ignore any line breaks you have entered into the code. If you want a line break you will have to insert a tag for it, like so:
<body>
I<br>
Love<br>
HTML.
</body>
|
Now the result will be:
I
Love
HTML.
Let's say you wanted an even bigger line break. Then you would use the <p> tag.
This lets the browser know that a new paragraph will begin. The <p> tag is the equivalent of two <br> tags.
For example the following code:
<body>
I<p>
Love<p>
HTML.
</body>
|
Will appear as:
I Love HTML.
The <br> and <p> tag do not need closing tags.
We can use the align attribute to control the alignment of paragraphs. For example:
|
<p align="right">This paragraph is aligned right.
<p align="center">This paragraph is aligned center.
<p align="left">This paragraph is aligned left. Will appear as:
|
Browsers also ignore extra spaces. To add an extra space add the tag . This tag is an example of a tag that does not have a less than and greater sign.
The following code:
|
<body>This code has ten extra spaces.</body>
|
Would appear as:
This code has ten extra spaces.
Notice how the result ignored any extra spaces that were typed.
To insure the spaces will appear, you must insert a tag for every space, like so:
|
<body>
This code has ten extra spaces.</body>
|
A very helpful tag is the <pre> </pre> tags. These tags will not ignore
all line breaks and extra spaces from your text editor. Here's an example:
| <pre>This text will appear
like so.
</pre> |
The result would be:
This text will appear
like so.
Next Lesson
|