Tags, Elements and Attributes
An HTML element represents a part of a document. Tags mark its boundaries and attributes add information; void elements such as img have no end tag or child content.
Identify an element, its tags and its attributes, including elements without end tags.
Every HTML page, however large, is built from one repeating shape. Once you can see that shape, you can read any page's source and spot mistakes such as a missing closing tag straight away.
The rule
Open, content, close; extra details ride in the opening tag.
An element has three parts:
<p class="note">Bring an umbrella.</p><p class="note">is the opening tag. The element's name,p, sits right after<.Bring an umbrella.is the content.</p>is the closing tag: same name, with a slash.
The class="note" part is an attribute. Attributes add information about the element and always follow the pattern name="value". They go only in the opening tag, separated by spaces. Quote your values with double quotes; it is the most common style and it avoids trouble when a value contains spaces.
Elements can hold other elements. This is called nesting, and the rule is that the last one opened is the first one closed:
<p>This is <strong>very</strong> important.</p>Some elements have no content at all, so they have no closing tag. These are void elements, for example <img>, <br>, <hr>, <input> and <meta>:
<img src="cat.jpg" alt="A ginger cat asleep on a chair">A few attributes are boolean: their presence alone means "yes". <input disabled> is disabled; there is no need to write a value.