Module 2: HTML Syntax and Attributes
Anatomy of an HTML Element
Distinguish tags, elements, attributes, and content by reading real markup.
An HTML element usually consists of a start tag, content, and an end tag. The tags mark where the element begins and ends; the element is the whole structure.
<p class="intro">HTML gives content a structure.</p>
Here, <p> is the start tag, </p> is the end tag, and the words between them are the content. The complete paragraph is the element. The class attribute gives the element a value that CSS and JavaScript can use.
An attribute belongs in the start tag and supplies extra information or changes an element’s behavior:
<a href="/learn/html/" title="Open the HTML course">Study HTML</a>
The href value gives the link its destination. Without it, the anchor is not a normal hyperlink.
Some elements contain other elements. A heading can be followed by a paragraph, and a link can contain text or an image. This parent-and-child relationship forms a tree. When debugging, identify the element first, then inspect its attributes and children. This is more reliable than thinking of HTML as a collection of decorative tags.