HTML provides almost complete control of the text layout of web pages allowing you to create well-formed documents - something vital for usability, accessibility and good search engine placement.
Headings
The heading element takes the form <hn>My Heading</hn> where n can take a value between 1 and 6 and 1 is the largest and 6 is the smallest.
The heading element supports a number of attributes; two of the most important are shown below.
The align attribute allows the heading to aligned left, right or centre. This attribute is depreciated under HTML 4.01 since it can be set using a style definition. e.g. <h1 align="center">My Heading</h1>
The class attribute. This important attribute tells the browser to render the heading in a named style and takes the form <h1 class="my_heading_style">My Heading</h1> where "my_heading_style" is a previously defined style.
Headings are important since they not only summarise the text content below them but allow a hierarchy of ideas using successively smaller headings and this is the key to a well-formed document.
Line Breaks
Browsers ignore carriage returns and white space when a document is rendered therefore tags must be used to break up text. The <br> element breaks to a new line and if you wish to break for more than one line then multiple break elements can be used.
The break element, which has no closing tag, has a number of attributes, including class, but one to note is the clear attribute. This is used to extend the wrapping options of text around objects such as images to ensure that any subsequent text begins below the object.
Left means that the text will appear at the first clear left margin - right means the text will appear at the first clear right margin - all means that both margins must be clear for the text to appear. This takes the form below.
<br clear="left">
The paragraph element also breaks to a new line and appears similar to break however there's a major difference. Paragraph has a closing tag and is a container element. Containers are important in HTML since they can be referenced by style definitions and JavaScript.
Paragraph has the same attributes as heading and similarly allows all the text within the paragraph to be aligned left, right or center. Also, as with heading, the class element allows all the text within the start and end tag to be rendered according to a previously defined style. Examples of paragraph are shown below.
Paragraph Examples
<p>My text</p>
<p align="center">My text</p>
<p class="my_paragraph_style">My text</p>
Horizontal Rules
Horizontal rules can break up sections of a document. The <hr> element has no closing tag but supports a number of attributes, the most important of which are shown below.
Align which takes the usual values of left, right or center.
Size which is the height of the rule in pixels.
Width which is the width of the rule and can be expressed in pixels or as a percentage.
Horizontal Rule Example
<hr align="center" size="10" width="50%">
Font
The font element is depreciated in HTML 4.01 since font can be set with style definitions. Setting font using style definitions is so much more useful than setting it with the font element that normally you shouldn't even consider using font tags and for this reason it's not covered here.
Emphasis
Sections of text can be emphasized using bold or italic tags. e.g. <b>Bold text</b> or <i>Italic text</i>
Special Characters
As already mentioned, white spaces are ignored by browsers therefore if you require more spaces than the initial space character, then has to be typed into the document.
The less than < and greater than > characters are treated by the browser as HTML tags therefore if you wish them to appear in your text then you need to type in < for less than and > for greater than.