Home > front end >  What is CSS selectors? And weight problems have precedence which elements can be inherited?
What is CSS selectors? And weight problems have precedence which elements can be inherited?

Time:09-24

the CSS selectors:

The id selector (id);
Class selectors (class);
Tag selector (div);
the wildcard selector (*)
(it's easy to forget)Adjacent selector (div + span);
Descendant selectors (div span);
Child selectors (div> Span);
Pseudo class selector (: hover);
Attribute selectors (a [rel="external"]); (less common)


element inheritance and cannot be inheritance:

Can inherit the style, color, font size, the font-family;
Can't inherit the style: width, height, padding, margins, border;


priority comparison:

Div selector (tag) (=1),
Class (class selectors) (=10),
Id (id selector) (=100),
! Important (=1000),
these selectors weights can stack!
  • Related