English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Complete CSS Selector Reference Manual
Use class="content" to select and set the style of all elements:
<!DOCTYPE html> <html> <title>Basic Tutorial Website(oldtoolbag.com)</title> <head> <style> .content { background-color:yellow; } </style> </head> <body> <h1>Welcome to my homepage</h1> <div class="content"> <p>My name is Tutu.</p> <p>I live in Canada.</p> </div> <p>My best friend is Lili.</p> </body> </html>Test to see ‹/›
.classA selector specifies the style for all elements of a class.
IEFirefoxOperaChromeSafari
All mainstream browsers support it.classSelector
Apply the style using class="myhome" to all <p> elements:
<!DOCTYPE html> <html> <title>Basic Tutorial Website(oldtoolbag.com)</title> <head> <style> p.myhome { background:red; } </style> </head> <body> <p>My name is Tutu.</p> <p class="myhome">I live in Canada.</p> <p>My name is Tutu.</p> <p class="myhome">I live in Canada.</p> </body> </html>Test to see ‹/›