Most of us have seen something like this before:
<div class="rights">All rights reserved!</div>
I just wanted to know, is this a right job? or althogh it will render in browser, it is better to use <p>
tag for example?
I am asking this to know if it has any Google(SEO), HTML Validity, ... issues/downsides.
Both div
and p
are block level elements. So, what is the reason to have a p
tag in HTML, when div
exists?
After more than 10 years, I want to answer my own question and share part of my knowledge and experience.
Using text directly inside div
tags is not semantically correct for meaningful content (like paragraphs), because div
is a generic block-level container with no semantic meaning. It is used primarily for grouping and styling.
Also:
p
conveys that the content is a paragraphp
improves accessibility, SEO and readability by screen readers and search engines.div
does not tell user agents or assistive technologies, what kind of content it contains.div
acceptable?When text is not meant to be semantically meaningful (like placeholder text or layout text).
For a clear examples, consider using div
for:
Even then, its better to use HTML5 semantic tags if possible.