Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 654
Pmpr.ir Avatar asked May 31 '14 06:05

Pmpr.ir


People also ask

Is it bad practice to put text in a div?

Yes, it is ok to use a <div> element without <p> .

Can you put text inside a div?

Any sort of content can be put inside the <div> tag! Note: By default, browsers always place a line break before and after the <div> element.

Does the div tag need a closing tag?

Div tag has both open(<div>) and closing (</div>) tag and it is mandatory to close the tag. The Div is the most usable tag in web development because it helps us to separate out data in the web page and we can create a particular section for particular data or function in the web pages.

Why is the div tag not semantic?

So, in web design, a semantic element is an element that has intrinsic meaning, and conveys that meaning to both the browser and the developer. For example, <div> and <span> are non-semantic elements. They tell us nothing about their contents.


1 Answers

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.

like image 121
Jean-François Savard Avatar answered Oct 25 '22 22:10

Jean-François Savard