HTML Elements, Tags and Correct Nesting
Elements and tags
An element represents a part of the document. For a paragraph, <p> is its opening tag, </p> is its closing tag, and the text between them is its content. Some elements, such as meta, are void elements: they cannot contain content and have no closing tag.
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>Notebook</title> </head> <body> <p>Bring a notebook.</p> </body></html>The browser displays the paragraph text, not the tags.
Nest elements in order
An element can contain another element when its content rules allow it. The strong element marks text of strong importance. Close the inner element before closing its parent.
<!doctype html><html lang="en"> <head> <meta charset="utf-8"> <title>Reminder</title> </head> <body> <p> Bring your <strong>ticket</strong> today. </p> </body></html>The word ticket is usually bold by default, while the whole sentence remains a single paragraph.
Common mistake: crossed closing tags
<p><strong>Notice</p></strong> is intentionally incorrect. Browsers may recover from invalid markup, but do not rely on that behavior. Write <p><strong>Notice</strong></p> instead. Practice marking one important word in a paragraph.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
HTML Elements, Tags and Correct Nesting — Knowledge Check
Apply the concepts and examples from this lesson.
Which part of <p>Read now</p> is the closing tag?
Which element in the document skeleton is void?
Which source correctly nests importance inside a paragraph?
What does strong communicate in the lesson example?
A browser displays crossed closing tags without an obvious error. What should you do?