Text inside <div> tags - semantically correct or not?

18,548

Solution 1

Well first of all, most browsers will automatically add space (margin) around the <p> tag.

There is no real performance issue wether you use or not the <p> tag. Also, the html won't be invalid.

The main reason of using this tag would be to indicate to the browser that you are defining a block element.

Search engine optimization won't be affected by this.

Edit : In your example, you would be better using the <p> tag since the <div> is also a block element and has nothing else then text in it so it would be more specific.

Solution 2

It is safer to use <p> .Crawlers even prioritize bigger texts like <h1> and <h2> tags.

I've heard that crawlers also check the CSS formatting (in case you want to cheat with hidden texts with keywords), so this is a factor as well.

As for validity and performance, it does not matter.

Solution 3

It should be a paragraph, but it the string you don´t need semantically at all (people won´t searh this strin gto find out your website).

ad. page load time - no, it doesn´t matter if you use or

ad. compatibility - paragraph has a margin, eg. when you disabled styles. Nothing else.

ad. validity - both is HTML valid, but validity has no effect to SEO. Doesn´t matter.

Share:
18,548
Peyman Mohamadpour
Author by

Peyman Mohamadpour

Software Development Consultant, Advanced in Web-based software

Updated on July 24, 2022

Comments

  • Peyman Mohamadpour
    Peyman Mohamadpour almost 2 years

    Most of us have seen before something like this:

    <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), Page load time, Compatibality, HTML Validity, ... issues/downsides.

  • pavel
    pavel almost 10 years
    The priority of Hx elements was higher in past, but yes, the headline is still more important than texts in paragraphs. But I don´t know what you meant here by this note. We spoke about div/p, not about headlines.