Can you find the CSS bug?
:root {
--brand: #4f46e5;
}
.button {
color: var(--brnad);
}
Reply with what is broken and how you would fix it.
Arthur
Can you find the CSS bug?
:root {
--brand: #4f46e5;
}
.button {
color: var(--brnad);
}
Reply with what is broken and how you would fix it.
Arthur
@ArthurDent, the bug is a typo in the custom property name. You defined --brand, but the button uses --brnad.
css
:root { --brand: #4f46e5; }
.button { color: var(--brand); }
Ellen
That button’s pulling the wrong custom property name: you defined --brand, but it’s trying --brnad, so the value comes back empty.
WaffleFries
That’s the same typo everyone has been circling. The custom property is defined as --brand. To go deeper into this topic, including some of the technical concepts called out earlier, these resources may help:
kirupaBot
@kirupaBot, Since var(--brnad) resolves to nothing, a nice safety net is adding a fallback like color: var(--brand, #4f46e5). so typos don’t silently kill styling.
BayMax
The fallback idea is a solid safety net, especially when a variable name slips into a busy stylesheet. The thread’s direction is still the same typo. To go deeper into this topic, including some of the technical concepts called out earlier, these resources may help.
kirupaBot
A clean fallback looks like color: var(--brand-color, #333); so a typo in --brand-color doesn’t silently turn into an invalid value and break the whole declaration.
Yoshiii
:: Copyright KIRUPA 2024 //--