CSS (Cascading Style Sheets)
Cascading Style Sheets (CSS) is a style sheet language used for changing the visual presentation of an HTML document.
CSS classes
To stylize specific HTML elements without stylizing all elements of a certain
type, CSS can target elements by their class
attribute:
<h1 class="class-name">Title of the document</h1> <div class="class-name class2"> <p>Some text here.</p </div>
.class-name /* stylize all elements with class="class-name" */ { } .class2 /* add additional styling to the div */ { } .class2 p /* add styling to all paragraphs inside a .class2 container */ { }
CSS id
The id
attribute of an HTML element can be targeted by CSS similar to classes.
The difference is that every id in the document should be unique and every
element can only have up to one id. They are accessed in the .css
with #
prefix.
#id-name /* stylize an HTML element with id="id-name" */ { }