Anatomy of an Element
| Part | Example | Meaning |
|---|---|---|
| Opening tag | <p> | Starts the element |
| Attribute | class="intro" | Extra information as name and value |
| Content | Hello world | What is inside |
| Closing tag | </p> | Ends the element |
The whole thing, from opening tag to closing tag, is one element.
Void Elements
Some elements have no content and no closing tag. They are called void elements.
Common Attributes
| Attribute | Use |
|---|---|
id | A unique name for one element on the page |
class | A reusable name for styling many elements |
href | Link destination |
src | File source for images, scripts and media |
alt | Text description of an image |
title | Extra tooltip text |
lang | Language of the content |
Nesting
Elements go inside other elements. Close the inner element before the outer one.
Comments
Character Entities
Some characters have special meaning in HTML. Use an entity to show them as text.
| To show | Write | Name |
|---|---|---|
< | < | less than |
> | > | greater than |
& | & | ampersand |
| Non-breaking space | | space that does not wrap |
| Copyright sign | © | copyright |
Block vs Inline
| Block elements | Inline elements | |
|---|---|---|
| Start on | A new line | The same line |
| Width | Take the full width | Only as wide as the content |
| Examples | div, p, h1, ul, section | span, a, strong, em, img |
display property, which you will learn later.
Practice
- Write a paragraph with one link and one bold word
- Show the text
<h1>on a page using entities - List three block and three inline elements
Conclusion
An element has tags, attributes and content. Nest tags correctly, use entities for special characters, and remember block elements take full rows while inline elements flow in text.

