Introduction

Overview

HTML stands for HyperText Markup Language. It is used on the front end and gives the structure to the webpage which you can style using CSS and make interactive using JavaScript.

Slides for this module

Elements

HTML consists of a series of elements, which you use to enclose, or wrap, different parts of the content to make it appear or act in a certain way. HTML elements are delineated by tags, written using angle brackets (< and >).

Element

The anatomy of our element is:

  • The opening tag: This consists of the name of the element (in this example, p for paragraph), wrapped in opening and closing angle brackets. This opening tag marks where the element begins or starts to take effect. In this example, it precedes the start of the paragraph text.

  • The content: This is the content of the element. In this example, it is the paragraph text.

  • The closing tag: This is the same as the opening tag, except that it includes a forward slash before the element name. This marks where the element ends. Failing to include a closing tag is a common beginner error that can produce peculiar results.

Document structure

HTML documents include a document type declaration and the <html> root element. Nested in the <html> element are the document head and document body.

There are several features that should be considered essential for any and every web page. Browsers will still render content if these elements are missing but include them. Always.

<!DOCTYPE html>

The first thing in any HTML document is the preamble. For HTML, all you need is <!DOCTYPE html>. This may look like an HTML element, but it isn't. It's a special kind of node called "doctype". The doctype tells the browser to use standards mode. If omitted, browsers will use a different rendering mode known as quirks mode. Including the doctype helps prevent quirks mode.

<html>

The <html> element is the root element for an HTML document. It is the parent of the <head> and <body>, containing everything in the HTML document other than the doctype. If omitted it will be implied, but it is important to include it, as this is the element on which the language of the content of the document is declared.

<head>

Nested between the opening and closing <html> tags, we find the two children: <head> and <body>

Code Boilerplate

Essential Tags

Reference: Link.

Last updated