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
Void (self-closing) elements
Some elements have no content and no end tag. They're called void elements.
| Element | Purpose |
|---|---|
<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
End tags start with </
Discussion
Loading…