HTML Tutorial – 04 – Whitespace

HTML Tutorial – 04 – Whitespace


In HTML all kinds of whitespace characters
are ignored. This means the page will render the same no matter how we format the text
and the text will contain no line breaks, except when it wraps around the edge of the
screen. To override this behavior we have several elements available. First, there is the break tag
that forcibly
breaks a line of text and creates a newline. A similar element is the paragraph

, which
adds more vertical space than the break tag. Its end tag is optional and we can align the
paragraph using the align attribute. Valid values for this attribute are left, right,
center, and justify. If we want to preserve the whitespace we can
use the preformatted element

. With this element the text will appear exactly as it's
typed in the document and it will be rendered with a fixed-width typeface. When we try to add more than one space character
in a row these will also be collapsed. To force spacing we need to use a non-breaking
space ( ). This character cannot be typed directly from the keyboard, instead we reference
it using a notation that starts with an ampersand  (&) and end with a semicolon (;). This notation
is used whenever we want to type a character that has special meaning, such as the angle
brackets. Lastly, we have the comment which is a special
kind of tag used only to include comments. It may span multiple lines and can appear
anywhere in the document. 

Leave a Reply

Your email address will not be published. Required fields are marked *