HTML Formatting and Colors (Page 1 of 6 )
In our last tutorial we left off discussing some basic HTML formatting. In this episode we will continue our discussion of formatting and get into working with Entities. There’s a lot to cover, so let’s get busy.
Last article I showed you a table with some text formatting. Here is another table displaying even more ways to format text:
Tag | What it Does | Example | Result |
<code> | Creates computer code text | <code>Hello</code> | Hello |
<kbd> | Creates keyboard text | <kbd>Hello</kbd> | Hello |
<samp> | Creates sample computer code text | <samp>Hello</samp> | Hello |
<var> | Creates variable text | <var>Hello</var> | Hello |
<pre> | Creates Preformatted text, which does not delete text or line breaks created by the user without tags. | <pre>Hello how are you doing good friend</pre> | Hello how are you doing good friend |
The above examples are used mostly to display examples of programming code, except the Preformatted tag <pre>, which is also used for formatting regular documents.
Consider this example:
<html>
<body>
<p>This is an example of what happens to white
space and
line breaks in HTML </p>
</body>
</html>
This is what happens when this code is translated by an Internet browser:
This is an example of what happens to white space and line breaks in HTML
As you can see, if there is more than one space between words, HTML is courteous enough to delete it for you. To prevent this innate courteousness, you can use the Preformatted tag <pre>. Check out this code:
<html>
<body>
<pre>This is an example of what happens to white
space and
line breaks in HTML </pre>
</body>
</html>
As you can see it is essentially the same text, except that I replaced the <p> tags with the <pre> tags. Here is how this new code will be interpreted by the browser:
This is an example of what happens to white
space and
line breaks in HTML
Next: Quotation, Acronyms, And More >>
More HTML Articles
More By James Payne