-
Selecting elements based on their id, name and class.
* is a universal selector
we can group elements with commas
Id, class name cannot start with numbers
-
with element.class we can also style some elements
Selectors
Types of selectors:
Simple Selectors
Selecting elements based on their id, name and class.
* is a universal selector
we can group elements with commas
Id, class name cannot start with numbers
with element.class we can also style some elements
Example
* { color: grey; }
Universally selected Example
h3, h4, h5 { text-decoration: underline; color: darkseagreen; }
.example { color: black; font-size: 18px; border: 1px solid grey; }
element.class example, this para elemets have a class name of example
#names { color: darkcyan; letter-spacing: 4px; }
This para has a id of names
This para element has a class of hello, css only selects a para element with class hello
Combinator Selectors
Using combinators(" ", >, +, ~) we can define the relation between the selectors and style them