CSS is not a pro-
gramming language
gramming language
Of course it is!
What are the main concepts
of OOP?
What are the main concepts
of OOP?
.myClass {
/* encapsulated! */
color: red;
font-weight: bold;
margin: 3rem;
}
Encapsulation, like how all the CSS properties are constained in a rule.
.red {
/* color is inherited! */
color: red;
}
<div class="red">
this is red
<div>...this too!</div>
</div>
Inheritance, like how the CSS properties flow down to the
children (+ the cascade).
children (+ the cascade).
<button class="btn">
styled button
</button>
.btn {
??????
}
Abstraction, how we can use a classes to style without knowing
what is inside.
what is inside.
<article class="awesome">
awesome article
</article>
<section class="awesome">
awesome section
</section>
.awesome { ... }
Polymorphism, like using the same class on different HTML elements.
CSS is not only a programming language, it is an object-oriented programm- ing language.