Your first HTML page
In the previous HTML example, we rushed a bit to avoid getting lost in too much talk.
This was the HTML we wrote:
I want to give you results, fast, and quick, and get you in motion as soon as possible. You now have an HTML page you can look at!
But that HTML file we saved didnāt really have all the elements a proper HTML file needs.
What do I mean?
Hereās a more correct version of that:
The elements we had before are wrapped into the body
tag.
That, along with head
(in this example empty), is contained in the html
tag, which is the root tag.
body
contains the visible elements of the page.
head
is used to contain special information about the content and more, as weāll see later.
In a document, we can have only 1 appearance of html
, body
and head
.
Finally, at the top we have the doctype: <!DOCTYPE html>
. This tells the browser āthis is an HTML fileā.
Notice I used an indentation of 2 characters for nested tags.
Nested tags should be indented.
In the example, the ul
tag contains the li
tags, so li
tags are nested.
Use 2 or 4 characters, or the tab
character to indent those nested elements, depending on your preference, but keep a ātree structureā. That will make it much easier to visually parse an HTML file.
Last updated
Was this helpful?