CSS Selectors
You've now learned about three kind of CSS selectors: type, class,
and ID!
●
Type selectors are used to apply a style to a particular type of HTML element, like
h1
or
body
.
Type selectors are written using just the type name.
●
Class selectors are used to set the style for multiple HTML elements that have a particular
value for the
class
attribute.
You can name a class anything you want! Class selectors are written with a dot before the
class: for elements such as
, the class selector is
.blue
.
●
ID selectors are used when the style is being
applied to one HTML element, which has to
have an
id
attribute.
There can be only
one element with a particular
id
on a page.
You can also choose any name
you want for an
id
, just like a
class
. ID selectors are written using a
#
sign: for an element
such as
, the
id
selector is
#sidebar
.
version 1.0