CSS
CSS (Cascading Style Sheets) is the stylesheet language used to control the visual presentation of HTML documents, defining layout, colors, typography, spacing, animations, and responsive behavior. Styles are applied via selectors that…
Definition
CSS (Cascading Style Sheets) is the stylesheet language used to control the visual presentation of HTML documents, defining layout, colors, typography, spacing, animations, and responsive behavior. Styles are applied via selectors that target HTML elements, with a cascade and specificity system determining which rules win when multiple rules conflict.
Overview
CSS was proposed by Håkon Wium Lie in 1994 and standardized by the W3C to separate a document's content (HTML) from its presentation, allowing the same markup to be styled differently across devices or contexts. A CSS rule consists of a selector (targeting elements by tag, class, ID, attribute, or relationship) and a declaration block of property-value pairs, such as `color: blue;` or `display: flex;`. The 'cascading' in its name refers to the algorithm that resolves conflicting rules using a combination of specificity, source order, and importance (`!important`). Modern CSS has grown far beyond simple text styling to include powerful layout systems: Flexbox for one-dimensional layouts, CSS Grid for two-dimensional layouts, and Container Queries for component-level responsive design — reducing the historical reliance on JavaScript or table-based hacks for layout. CSS also includes transitions and keyframe animations for motion design, custom properties (CSS variables) for theming and dynamic values, and media queries that adapt styles based on viewport size, device type, or user preferences (like `prefers-color-scheme` for dark mode). Because CSS specifications are developed modularly by the W3C's CSS Working Group, new features (like `:has()`, nesting, and `@container`) ship incrementally rather than as monolithic version bumps. CSS is typically authored directly, through preprocessors (Sass, Less), or via utility-first frameworks (Tailwind CSS) and CSS-in-JS solutions, but all ultimately compile down to standard CSS that browsers interpret.
Key Features
- Selector-based rules targeting HTML elements by tag, class, ID, or relationship
- Cascade and specificity system for resolving conflicting styles
- Flexbox and Grid for modern one- and two-dimensional layouts
- Media queries and container queries for responsive design
- Custom properties (CSS variables) for theming and dynamic values
- Transitions and keyframe animations for motion without JavaScript
- Pseudo-classes and pseudo-elements for state and structural targeting
- Modular, continuously evolving specification via the W3C CSS Working Group