Formatting
- HTML includes many formatting tags to help text stand out.
- Formatting tags can be nested, but must be closed in the correct order.
Common Formatting Tags
HTML includes a large number of tags made for formatting text. The two most common formatting tags are <i> (italics) and <b> (bold). Other common formatting tags include super and subscripts (<sub> and <sup>), computer output
(<code>), and
preformatted text (<pre>).
Click to view Live Example
The two most common formatting tags are <i>italics</i> and <b>bold</b>. Other common formatting tags include <sup>super</sup> and <sub>sub</sub>scripts, <code>computer output</code>, and <pre>preformatted text</pre>.
Examples of common formatting tags
More Formatting Tags
<big> and <small> can control the size of text, while <ins> and <del> can show document proofreading editing. HTML also helps quoting large peices of text using <blockquote>:
This is a long quote and would appear on multiple lines in a printed text. So, it needs to be in a blockquote rather than an inline quote surrounded by quotation marks. This is a long quote and would appear on multiple lines in a printed text. So, it needs to be in a blockquote rather than an inline quote surrounded by quotation marks. This is a long quote and would appear on multiple lines in a printed text. So, it needs to be in a blockquote rather than an inline quote surrounded by quotation marks.
Click to view Live Example
<p>big and small can control the <big>size</big> of <small>text</small>, while ins and del can show document <del>proofreading</del> <ins>editing</ins>. HTML also helps quoting large peices of text using blockquote:</p>
<blockquote><p>This is a long quote and would appear on multiple lines in a printed text.</p></blockquote>
More formatting examples
Using Formatting Tags
All of the formatting tags can be used anywhere within an HTML document that printed text appears. For example, within a paragraph (<p>) or link (<a>). This is made possible by HTML's support of element nesting as discussed in the previous section. Note also that two formatting tags can be nested to combine their properties, but it is important to close the tags in the correct order. See the example below:
Click to view Live Example
Two formatting tags can be <i><b>nested</b></i> to combine their properties.
Nesting multiple formatting tags
Since the bold tag is opened last, it is closed first. Remember that only complete HTML elements can be nested, and elements include the start tag, content, and end tag. When writing HTML, it is always a good idea to close a tag right after opening it and then add the content last, so that the end tag will be in the correct place.