3 Text in HTML

3.1 Lines and Paragraphs

A paragraph in HTML is anything enclosed by <p>...</p>. In fact most of the time you can leave the closing tag off and just leave a blank line after it, as it's usually clear when a paragraph has ended, but browsers often get confused and it is safer to always include the end tag as well. It is especially important to include the </p> when you start using styles (see later).

Browsers display text in a paragraph with a single space between the words, and a new line whenever necessary. The browser will ignore any extra space or blank lines in the HTML source, so it doesn't matter how the source document is set out.

Sometimes you might want to end a line early, or have a blank line to separate out the content, and you can do this with the <br> tag. As the <br> tag causes a line break immediately rather than defining a region, there is no need for an ending tag. Note that multiple consecutive <br> tags is only required to produce one line break, so this is not a good way to create extra vertical space.

3.2 Headings

You might want to have headings on your page to use as titles for pages, sections etc. There are six styles of heading defined in HTML:

<h1>...</h1>

Heading 1

<h2>...</h2>

Heading 2

<h3>...</h3>

Heading 3

<h4>...</h4>

Heading 4

<h5>...</h5>
Heading 5
<h6>...</h6>
Heading 6

Exactly how these various headings will appear is left up to the browser, but they will always be ordered in diminishing importance such that <h1>...</h1> is the most significant (usually the largest) and <h6>...</h6> the least significant.

Exercise 3

Add a large heading to your page, followed by a short paragraph explaining who you are. Be sure to include the fact that you are studying (or working) at the University of York. It should end up looking something like this.


Previous page Next page