I am somewhat new to UI development, but I am very much uncomfortable with how CSS actually works.My use-case : [ Attempted with css & less ]I wanted to apply some specific styles inside a particular \[code\]div\[/code\] on a page.css attempt :\[code\]div.class1 { font: normal 12px arial, helvetica, sans-serif; font-color: #f30;}div.class1 div.class2 { border: 1px solid #f30;}\[/code\]less attempt :\[code\]@red: #f30;@font-family: arial, helvetica, sans-serif;div.class1 { font: normal 12px @font-family; font-color: @red; div.class2 { border: 1px solid @red; }\[/code\]
- Now, writing css can induce bugs since it forces you to repeat \[code\]#f30\[/code\] & \[code\]div.class2\[/code\] everytime you try to achieve hierarchy and variable re-use.
- Why is that css makes things difficult ?
- less does nothing special - just makes obvious improvements and translates to css ?
- What is that css wants to motivate in users because of which it promotes such a redundant coding style ?