r/ProgrammerTIL • u/zeldaccordion • Feb 12 '19
Other Language [HTML][CSS] TIL native CSS variables exist, as well as 4 other TILs for pure HTML and CSS
I tried to avoid a clickbait title by putting one of the best TILs in the title, but really this whole article was a big TIL batch of 5 for me: Get These Dependencies Off My Lawn: 5 Tasks You Didn't Know Could be Done with Pure HTML and CSS
They're all really good. But my favorite is the CSS variables.
:root { --myvar: this is my vars value available from the root scope; }
#some-id-to-use-var-in { content: var(--myvar);}
58
Upvotes
6
u/robin_888 Feb 21 '19
A year ago I started a job as web developer.
For my first website I found this and used it (mainly for colors).
A week later I tested the website on IE.
And I learned why CSS variables aren't more common.
21
u/fyrilin Feb 12 '19
As long as you don't have to support actual IE because government/university clients. Sigh
4
u/EternallyMiffed Feb 12 '19
You don't really need to use
:rootthough. I don't know what your target environment is buthtmlwill suffice.2
u/VIM_GT_EMACS Feb 12 '19
They sure are shit at design. Who puts orange links on teal background?