My solution
100% match, 118 characters
<p><style>*{background:var(--m,#588A95);*{width:140;height:140;margin:20%auto;--m:#222;*{--m:#fff;transform:skew(45deg Explanation:
- Make sure you understand the CSSBattle environment
- The ungolfed version looks like this:
<style> * { background: var(--m, #588A95); * { width: 140px; height: 140px; margin: 20% auto; --m: #222; * { --m: #fff; transform: skew(45deg); } } } </style> <p></p> Syntax Overview
The syntax:
* { * { * { } } } is called CSS nesting
Understanding Nested CSS Example
In this case, it is the same as:
html {} body {} p {} Instead of writing:
html { background-color: var(--m, #588A95); } body { width: 140px; height: 140px; margin: 20% auto; background-color: var(--m, #222); } Since they share the same background-color property, we can do something like:
html { background-color: var(--m, #588A95); body { width: 140px; height: 140px; margin: 20% auto; --m: #222; } } Here, the body element inherits the background-color from html, but it can also define its own background color value (#222).
Step-by-Step Breakdown
1. First Level
* { background-color: var(--m, #588A95); } The
*selector here matches thehtml,bodyandpelement.This styles the
html,body, andpelements with a background color set to the variable--m, or#588A95if--mis not defined.
2. Second Level
* { width: 140px; height: 140px; margin: 20% auto; --m: #222; } At this level:
The
*selector here matches thebodyandpelement.The
widthandheightofbodyandpare set to140px.The elements are centered horizontally with margin:
20% auto.The variable
--mis now defined as#222, which will be used as the background color for these elements.
3. Third Level
* { --m: #fff; transform: skew(45deg); } Finally:
- The
*selector here matches thepelement.
The --m variable is updated to #fff, so the p element now has a white background.
The element is also transformed with a 45-degree skew.
✅ Summary:
This nested structure allows each level of the cascade (html → body → p) to inherit and override the CSS variable --m, resulting in a layered color change and transformation effect.
Top 10 solutions (maximum 110 characters):
1. Ilya Streltsyn
<style>*{background:#588A95;color:#222;outline:solid 75q;margin:37.5%50%;*{color:fff;transform:skew(45deg 2. emohdaziz
<stYle>&{background:#222;border:138Q solid#588a95;scale:1 3.5;*{background:#fff;margin:0;transform:skew(74deg 3. Mister Magoo
<p><style>*{background:var(--b,#588A95)}&>*{margin:80 130;--b:#222}p{--b:#fff;height:140;transform:skew(45deg 4. Seth Kuhn
<style>&{border:138q solid#588A95;background:#222;margin:-50 0;*{background:#fff;margin:0;transform:skew(45deg 5. Ludvig
<STYLE>&{background:#222;margin:-50 0;border:138q solid#588A95;*{background:#FFF;margin:0;transform:skew(45deg 6. H_Bliertz
<p><stylE>&{margin:142 192;*{background:#588A95;outline:solid 75q;color:#222;*{color:#FFF;transform:skew(45deg 7. Martijn
<style>&{background:#222;border:138q solid#588A95;margin:-50 0;*{background:#fff;margin:0;transform:skew(45deg 8. David Eguiluz
<style>&{background:#222;border:138q solid#588a95;margin:-50 0;*{background:#fff;margin:0;transform:skew(45deg 9. Kieron
<style>&{margin:-58-8;background:#222;border:46vh solid#588a95;*{margin:0;background:#fff;transform:skew(45deg 10. Sascha Adams
<stYle>&{background:#222;border:138q solid#588A95;margin:-50 0;*{margin:0;background:#fff;transform:skew(45deg

Top comments (0)