CSS code
CSS code, short for Cascading Style Sheets code, is the language used to describe the presentation of documents written in HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS describes how elements should be rendered on screen, on paper, in speech, or on other media. It is a cornerstone technology of the World Wide Web, alongside HTML and JavaScript.
CSS separates content from presentation. Instead of including styling information directly within HTML documents, CSS allows developers to define styles in separate files (or within <style>
tags), making it easier to maintain a consistent look and feel across an entire website.
The term "CSS code" broadly refers to the rulesets that make up a CSS stylesheet. A ruleset consists of a selector and a declaration block. The selector specifies which HTML elements the style applies to. The declaration block contains one or more declarations, each consisting of a property and a value. The property specifies which aspect of the element to style (e.g., color, font-size), and the value specifies the desired style for that property.
CSS code allows for a wide range of styling options, including controlling colors, fonts, layout, spacing, and more. It supports features like selectors for targeting specific elements, cascading rules to resolve conflicting styles, and inheritance, where elements inherit styles from their parent elements. Specificity determines which style rule takes precedence when multiple rules apply to the same element.
Different levels of CSS exist, indicated by numbers (e.g., CSS1, CSS2, CSS3). Each level introduces new features and capabilities. CSS3, and subsequent evolutions of CSS, are modular, meaning that they are divided into separate modules, each addressing a specific area of styling, such as selectors, text effects, or animations. Browser support for different CSS features varies.
CSS preprocessors like Sass and Less extend the capabilities of CSS by adding features like variables, nesting, and mixins, which can simplify the process of writing and maintaining CSS code. These preprocessors require compilation to standard CSS before a browser can render them.