HTML ELEMENTS
HTML elements are the fundamentals of HTML. HTML documents are simply a text file made up of HTML elements. These elements are defined using HTML tags. HTML tags tell your browser which elements to present and how to present them. Where the element appears is determined by the order in which the tags appear.
HTML consists of almost 100 tags. Don't let that put you off though - you will probably find that most of the time, you only use a handful of tags on your web pages. Having said that, I highly recommend learning all HTML tags eventually - but we'll get to that later.
OK, lets look more closely at the example that we created in the previous lesson.
HTML Tutorial Example
Less than 5 minutes into this HTML tutorial and
I've already created my first homepage!
Explanation of the above code:
Closing your tags
As mentioned in a previous lesson, you'll notice that all of these tags have opening and closing tags, and that the content of the tag is placed in between them. There are a few exceptions to this rule.
You'll also notice that the closing tag is slightly different to the opening tag - the closing tag contains a forward slash (/) after the <. This tells the browser that this tag closes the previous one.
UPPERCASE or lowercase?
Although most browsers will display your page regardless of the case you use, you should always code in lowercase. This helps keep your code XML compliant (but that's another topic).
In the next lesson, we learn about some of the more common formatting tags.
HTML FORMATTING
You may be familiar with some of the formatting options that are available in word processing applications such as Microsoft Office, and desktop publishing software such as QuarkXpress. Well, many of these formatting features are available in HTML too! This lesson contains some of the more common formatting options.
Headings
There is a special tag for specifying headings in HTML. There are 6 levels of headings in HTML ranging from h1 for the most important, to h6 for the least important.
Typing this code:
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Results in this:
Heading 1
Heading 2
Heading 3
Heading 4
Heading 5
Heading 6
Bold
You specify bold text with the tag.
Typing this code:
This text is bold.
Results in this:
This text is bold.
Italics
You specify italic text with the tag.
Typing this code:
This text is italicised.
Results in this:
This text is italicised.
Line Breaks
Typing this code:
Results in this:
Horizontal Rule
Typing this code:
Here's a horizontal rule...
...that was a horizontal rule :)
Results in this:
Here's a horizontal rule...
...that was a horizontal rule :) Unordered (un-numbered) List
Typing this code:
- List item 1
- List item 2
- List item 3
Results in this:
- List item 1
- List item 2
- List item 3
Ordered (numbered) List
Note, that the only difference between an ordered list and an unordered list is the first letter of the list definition ("o" for ordered, "u" for unordered).
Typing this code:
- List item 1
- List item 2
- List item 3
Results in this:
- List item 1
- List item 2
- List item 3
We will be covering more HTML tags throughout this tutorial, but before we do that, you should know about attributes.