Family of markup languages for displaying information viewable in a web browser.
HTML elements are the building blocks of HTML pages. They provide the structure for web content and ensure that a web browser can interpret and display the content correctly. This unit will delve into the details of HTML elements, their attributes, and how they are used.
An HTML element usually consists of a start tag and an end tag, with the content inserted in between. For example, <p>
is a start tag, </p>
is an end tag, and any text placed between these tags is paragraph content.
HTML elements can have attributes, which are additional values that configure the elements or adjust their behavior in various ways. The attributes are always specified in the start tag. For instance, the href
attribute in the <a>
tag is used to specify the URL of the page the link goes to.
HTML elements can be divided into block-level elements and inline elements. Block-level elements form a visible block on a page and appear on a new line from the content that precedes and follows them. Examples include <div>
, <p>
, and <h1>
to <h6>
.
Inline elements, on the other hand, do not start on a new line and only take up as much width as necessary. Examples include <span>
, <a>
, and <img>
.
Empty elements are HTML elements with no content. They are also called void elements. These elements cannot have an end tag because they cannot contain any content. Examples include <br>
for a line break and <img>
for an image.
HTML elements can be nested, which means that elements can contain other elements. It's important to remember that the tags must be closed in the correct order. For example, if you have a <p>
element that contains a <b>
element, the </b>
tag must be closed before the </p>
tag.
HTML entities are used to display reserved characters in HTML that cannot be used in your HTML because they are part of the HTML language. For example, to display a less than sign (<) we must write <
or <
in the HTML document.
By understanding these concepts, you can start to see how HTML elements form the structure of web pages. In the next unit, we will explore more advanced HTML concepts.