BEM
Block Element Modifier
A CSS naming convention using block__element--modifier format to create reusable, maintainable class names.
Teknik Detay
CSS BEMs (--*) differ from preprocessor variables: they cascade, inherit, and can be modified at runtime with JavaScript via element.style.setProperty(). They participate in the cascade and specificity system. The var() function accepts a fallback value: var(--color, #000). Custom properties enable dynamic theming, design tokens, and component-scoped styling without JavaScript framework overhead. They are computed at used-value time, enabling animations and transitions on custom properties.
Ornek
```css
:root {
--color-primary: oklch(0.65 0.24 265);
--spacing-md: 1.5rem;
--radius: 0.5rem;
}
.btn {
background: var(--color-primary);
padding: var(--spacing-md);
border-radius: var(--radius);
}
```