
Void element HTML can be a bit tricky to understand, but don't worry, I'm here to break it down for you in simple terms.
Void elements are a type of HTML element that don't have a closing tag, and they're used to define things like images, links, and line breaks.
Self-closing tags, on the other hand, are a way to write void elements in HTML.
In HTML5, void elements are no longer required to have a space between the tag name and the slash, making them look like self-closing tags.
Mental Model and Usage
Having the right mental model about HTML is crucial for learning, teaching, and designing tools. HTML has a discrete set of void elements hardcoded into its parsers.
People who write HTML need to learn and remember which elements are void, without relying on trailing slashes to indicate their special status. The HTML standard explicitly states that trailing slashes in void elements are unnecessary and have no effect.
Using trailing slashes in void elements can create a misleading mental model of HTML, where the trailing slash appears to have special significance. This can lead to confusion and incorrect usage.
It's essential to promote the correct mental model of HTML, where void elements are clearly defined and don't require trailing slashes. This ensures that HTML writers can focus on the actual structure and content of their code.
You might like: Html Css Box Model
Featured Images: pexels.com


