+ 3

different between class p.italic and a normal .italic

Hello, I can´t see the different between the a normal class .italic { font-style: italic; } and the used one p.italic { font-style: italic; } When should I use which one of them? Best regards

1st Nov 2016, 8:08 AM
Ronny Ruhe
Ronny Ruhe - avatar
3 Respuestas
+ 5
If your website has only paragraphs with italic class, yes there is no difference. But if you have links with italic class too .italic will select everything with "italic" class name but p.italic will only select paragraphs, not links. For example <a class="italic" href="page.html"> Link </a> <p class="italic">This is an italic pragraph</p> <p>This is another pragraph</p> If you want to change color of italic paragraph, you should use p.italic { color: red; }. If you use .italic { color: red; }, it will change color of link too.
2nd Nov 2016, 5:49 AM
Bekir Uzun
Bekir Uzun - avatar
+ 3
Perfect, thank you Bekir. That really makes sense :)
2nd Nov 2016, 5:54 AM
Ronny Ruhe
Ronny Ruhe - avatar
+ 1
thanks
20th Aug 2017, 5:26 PM
Vicky Ingle
Vicky Ingle - avatar