The "class" in html and css | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

The "class" in html and css

So in The HTML: <h1>.......</h1> <p class="example">......</p>. The CSS: h1 {.........} p.example{....} so why h1 has no "class" and p has "class"? i don't know where i missed that, please help, Thanks!

24th Sep 2016, 8:28 AM
Keze khusoh
5 Answers
+ 1
Classes are a way to categorize html elements. You can then apply a style to all the elements sharing the same class at once for example.
24th Sep 2016, 8:39 AM
Zen
Zen - avatar
+ 1
<style> is for when you want to insert css in an html document. Prefer using a separate css file if possible.
24th Sep 2016, 9:51 AM
Zen
Zen - avatar
0
h1 can also have class attribute <style> .d{color:blue;} </style><h1 class=d>This is a Blue Heading</h1>
24th Sep 2016, 8:46 AM
рооройрпЛроЬрпНроХрпБрооро╛ро░рпН рокро┤ройро┐роЪрпНроЪро╛рооро┐
рооройрпЛроЬрпНроХрпБрооро╛ро░рпН рокро┤ройро┐роЪрпНроЪро╛рооро┐ - avatar
0
thanks for the answer. btw ManojKumar, for that code is the style tag necessary or can do without it just : .d{color:blue;} ?
24th Sep 2016, 9:06 AM
Keze khusoh
0
aha thanks i get it now!:)
24th Sep 2016, 10:29 AM
Keze khusoh