Reputation: 583
I feel <div>
and <span>
are important but the rule or my reference notes say:
When only when no other HTML element is applicable you can use
<span>
and<div>
What is the importance of this limitation?
Upvotes: 2
Views: 1131
Reputation: 583
This chart from the HTML5 Doctor Web site may help you decide whether or not to use a <div>
:
Upvotes: 2
Reputation: 163301
<span>
and <div>
don't convey much meaning about the structure of the document. They're more for utility.
Ideally, your HTML indicates something about document structure. If you use <h1>
, the browser knows, "this is a top level heading". If you use <p>
, the browser knows, "this is a paragraph". This is important because not everything using your HTML is going to be a web browser your CSS rules.
Search engines, for example, use the structured document to determine what sort of content is on your page. If it's all just text with no structure, the indexing algorithms can't know what's important and what isn't.
Upvotes: 5