What Is a Regular HTML Element?
A regular HTML element consists of an opening tag, content, and a closing tag.
Here’s an illustration:
Below are some of the widely used regular HTML elements.
What Is an <html>
Element?
An <html>
element informs browsers that the content between its opening and closing tags is an HTML document.
An <html>
element typically gets placed after the <!DOCTYPE>
declaration.
Here’s an example:
What Is a <head>
Element?
A <head>
element informs browsers that the content between its opening and closing tags is strictly metadata for machine processing.
An HTML document’s title, scripts, and stylesheets are some of the content placed inside the <head>
element.
A <head>
element is typically the first element inside an <html>
node.
Here’s an example:
What Is a <body>
Element?
A <body>
element informs browsers that the content between its opening and closing tags is the HTML document’s content for human interaction.
A <body>
element is typically the second element inside an <html>
element (after the <head>
element).
Here’s an example:
What Is a <header>
Element?
A <header>
element annotates the introductory content of an HTML document (or the introductory content of a section within the document).
Here’s an example:
You can use multiple <header>
elements on an HTML page—but not in a <footer>
, <address>
, or another <header>
element.
What Is a <nav>
Element?
A <nav>
element annotates the main navigation links of an HTML document—for instance, the site’s menu.
Here’s an example:
What Is an <aside>
Element?
An <aside>
element annotates an HTML document’s content that is indirectly related to another content—for instance, a document’s sidebar or an article’s sidenote.
Here’s an example:
A slick computer trick that makes mistakes disappear
What Is a <main>
Element?
A <main>
element annotates the <body>
element’s primary content.
Here’s an example:
What Is an <article>
Element?
A <article>
element annotates an independent content.
In other words, suppose you isolate the <article>
element. In such a case, its content should still be meaningful to users.
Therefore, an <article>
element should be reusable in other parts of the same application (or in a different application).
Here’s an example:
A blog article, gadget review, or tutorial are examples of content you can annotate with the <article>
element.
What Is a <section>
Element?
A <section>
element annotates a sectional content of the <body>
element.
Each section typically contains a heading.
Here’s an example:
What Is a <div>
Element?
A <div>
element is a block-level container for grouping the generic content of an HTML document.
Here’s an example:
Design in Figma, launch in Webflow
What Is a <span>
Element?
A <span>
element is an inline-level container for grouping the generic content of an HTML document.
Here’s an example:
What Is a <form>
Element?
A <form>
element informs browsers that the content between its opening and closing tags are interactive HTML elements for submitting information.
Here’s an example:
The action
and method
attributes are essential.
The action
attribute specifies where browsers should send the form’s data once users submit it.
The method
attribute defines the HTML method browsers should use to submit the form’s data to the specified destination.
A form’s method
attribute accepts a case-insensitive "post"
or "get"
value.
Suppose you omit the method
attribute. In that case, browsers will automatically use the "get"
request method to send the form’s data.
Let’s discuss some widely used elements a <form>
can contain.
HTML <button>
element
A <button>
element creates a clickable button.
Here’s an example:
The type
attribute is essential. It tells browsers the type of button you wish to create. If omitted, browsers will:
- Default to
type="submit"
- Attempt to submit the form’s data whenever users click the button
Therefore, users may experience unusual behaviors such as a page reload on-click of the button.
HTML <select>
element
A <select>
element creates a drop-down menu list.
Here’s an example:
The name
attribute is essential. It makes it possible to reference the form’s data on the server.
Build your website with Namecheap
HTML <label>
element
A <label>
element creates caption for a form’s interactive elements like <select>
, <input>
, and <textarea>
.
Here’s an example:
The snippet above nested the <select>
element directly inside the <label>
to bind the two together. But you can tidy up the association by defining the for
and id
attributes on the <label>
and <select>
elements.
Here’s an example:
The for
attribute’s value must be the same as the element’s id
to which you are binding the <label>
. For instance, in the snippet above, <select>
’s id
value is equivalent to <label>
’s for
attribute’s value.
Here are some advantages of the <label>
element:
- It increases an element’s hit (clickable) area. Therefore, it improves the accessibility of the
<select>
,<meter>
,<progress>
,<textarea>
, and<input>
elements. <label>
makes it easier for assistive technology users to use the associated element—as screen readers will read out the label when users focus on the form input.
HTML <option>
element
An <option>
element creates the list of options contained in a <select>
, <optgroup>
, or <datalist>
element.
Here’s an example:
The value
attribute is essential. It states the value browsers should send to the server when users submit the form.
HTML <fieldset>
element
A <fieldset>
element is a block-level container for grouping the related content of a form.
Here’s an example:
Design in Figma, launch in Webflow
HTML <legend>
element
A <legend>
element creates a caption for its parent <fieldset>
element.
Here’s an example:
What Is an <a>
Element?
An <a>
element links the content between its opening and closing tags to other data.
Here’s an example:
The href
attribute is essential. It specifies the URL you wish to link the anchor element’s content.
The two (2) types of anchor links are:
- External links
- Internal links
Let’s discuss the two anchor element types below.
What is an external link?
An external anchor links an <a>
element’s content to another data on a different website.
Here’s an example:
The snippet above used an absolute URL to link the anchor element’s content to an external webpage.
What is an internal link?
An internal anchor links an <a>
element’s content to another data on the same website.
Here’s an example:
The snippet above used a relative URL to link the anchor element’s content to an internal webpage.
You can also create an internal jump link to a specific part of the same page.
Here’s an example:
Here’s what we did in the snippet above:
- We defined an
id
attribute on the<h2>
element. - We initialized the
<a>
element’shref
with the<h2>
’sid
value—which we prefixed with a hash symbol (#
).
Therefore, suppose users click the <a>
element’s text. In that case, the page will move up to the “Introduction” heading.
Express Your Love for Coding!
What Is a <footer>
Element?
A <footer>
element informs browsers that the content between its opening and closing tags is the footer data for its enclosing document (or section).
Here’s an example:
What Is an <address>
Element?
An <address>
element informs browsers that the content between its opening and closing tags is a contact detail.
Here’s an example: