iwantcoding.com
🔥 Daily 👥 Rooms 🏆 Top Log in Sign up

HTML Elements

An HTML element is everything from the start tag to the end tag, including the content in between. Most elements come in pairs; a few stand alone.

Anatomy of an element

<p> Hello, world. </p> start tag content end tag
Fig 1. A paired element: start tag, content, end tag.

Void (self-closing) elements

Some elements have no content and no end tag. They're called void elements.

ElementPurpose
<br>A line break inside text.
<hr>A thematic horizontal rule.
<img>Embeds an image.
<input>A form input field.
<meta>Metadata in the document head.
<link>Links to external resources such as stylesheets.
Tip: Tag names are case-insensitive (<P> works), but the convention is lowercase. Always close paired elements — modern browsers forgive a lot, but mistakes still break layouts.

Example

Example
<!DOCTYPE html>
<html>
<head>
    <title>HTML Elements</title>
</head>
<body>

<h1>HTML Elements</h1>
<p>This is a demo page for the "HTML Elements" lesson.</p>

</body>
</html>
Try it Yourself »

Exercise

Add the missing end tag so the paragraph is well-formed.

<p>This is a paragraph

Test yourself

Q1. An HTML element is made of…
Q2. Which of these is a void (self-closing) element?
Q3. Are HTML tag names case-sensitive?

Discussion

Loading…