-
Notifications
You must be signed in to change notification settings - Fork 96
03. HTML Structure
To create a new file, use the new file icon in the side bar. Create a file called index.html ensuring your add the .html file extension.
HTML is a mark-up language with tags or elements assigning specific roles to each part of the document. Tags generally consist of an opening and closing pair. They are written in lower case using angled brackets ie <html>.
Our first HTML tag (or element) will open and close the entire document.
Open index.html. It will be blank. Add the following:
<html>
</html>Tip: With Visual Studio Code you can simply type html and then hit tab to add the above.
Inside of the <html> element go all the other HTML elements required to create our page. A HTML document consists of a head and body. The head is where information about the file is placed, the body is where the visual content of the page is placed. Unless otherwise stated the bulk of HTML element are place inside the <body> tag.
Warning
A HTML file should only have one <head> and one <body> element.
Extend your code as follows:
<html>
<head>
</head>
<body>
</body>
</html>HTML has a strict hierarchy that dictates which tags can be placed inside of which. As such the <html> element is the parent of all the other elements in HTML.
Tip
It may help you to indent tags as in the above example. White spacing is ignored by the web browser so feel free to use as much as you like to make your documents more readable.