Is there always class with div tag in html | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is there always class with div tag in html

5th Jun 2019, 1:00 PM
YOGESH KUMAR
9 Answers
+ 5
No...not necessary...even any tag may have or may not have class. It's depends upon your requirements. If you want to get value or you want to apply css then you can use class or id otherwise no need.
21st Jun 2019, 1:28 PM
A͢J
A͢J - avatar
+ 4
Hey I was just kidding !!
5th Jun 2019, 3:48 PM
Ayan Fox
Ayan Fox - avatar
+ 3
Still can not understand what p1 is. 😁😆
5th Jun 2019, 3:43 PM
Ayan Fox
Ayan Fox - avatar
+ 2
Nope. You need to add one or more. Div is div.
5th Jun 2019, 1:02 PM
Ayan Fox
Ayan Fox - avatar
+ 2
River what do you mean ? I don't understand.
5th Jun 2019, 2:13 PM
Ayan Fox
Ayan Fox - avatar
+ 2
Wh-ok lol 👍😁
5th Jun 2019, 3:50 PM
River
River - avatar
+ 1
No!
5th Jun 2019, 2:11 PM
CodeFu
CodeFu - avatar
+ 1
Making myself alot clearer.Answer was rushed. Sorry. <div> tags don't need exactly 'class' in them. They are used to divide portions of your webpage. For example <div> <p1>This is a paragraph</p1> </div> Or you could have <div style="color:blue";> <p1>This is a paragraph</p1> </div> Then all the text in this <div> will appear blue. When you are using class= in a similar fashion, it usually connects to CSS code, and the id= can lead to both Javascript and CSS. So in conclusion, no, you don't have to all the time. Sorry about the first post. I have deleted it. I was on my way out abd totally misread it. Hope this helps now!!
5th Jun 2019, 3:41 PM
River
River - avatar
+ 1
<p1> standa for paragraph 1. </p> It's that simple. All the text between those two tags will be in the same paragraph form.
5th Jun 2019, 3:47 PM
River
River - avatar