본문 바로가기
Web Dev

Intermediate CSS - PART III (Refactoring II, Selector Priority)

by YGSEO 2020. 12. 27.
728x90

Refactoring

Give colored-section to each section

And remove css with the same stylings.


Selector Priority

inline styles are more specific than internal or external CSS styles.

As you can see, inline style overrides external CSS.


h1 element VS. class VS. Id

Id style overrides all the other styles.

Even though I changed the order of class and id, id style overrides all since it's more specific.


Tips for preventing error-prone selector rule.

  • Always consider to use "class" not "id" even if it only appears once.
  • Try to keep it specific and apply only a single custom class to each of elements.
  • Avoid inline styles at all costs.

 

 

 

728x90

댓글