CSS

From Canonica AI

Introduction

Cascading Style Sheets (CSS) is a style sheet language used for describing the look and formatting of a document written in a markup language. Although most often used to change the style of web pages and user interfaces written in HTML and XHTML, the language can be applied to any kind of XML document, including plain XML, SVG and XUL. CSS is a cornerstone technology of the World Wide Web, alongside HTML and JavaScript.

History

CSS was first proposed by Håkon Wium Lie on October 10, 1994. At the time, Lie was working with Tim Berners-Lee at CERN. Several other style sheet languages for the web were proposed around the same time, and discussions on public mailing lists and inside W3C resulted in the first W3C CSS Recommendation (CSS1) being released in 1996.

A timeline showing the evolution of CSS from 1994 to present.
A timeline showing the evolution of CSS from 1994 to present.

Syntax

CSS has a simple syntax and uses a number of English keywords to specify the names of various style properties. A style sheet consists of a list of rules. Each rule or rule-set consists of one or more selectors, and a declaration block.

Selectors

In CSS, selectors declare which part of the markup a style applies to by matching tags and attributes in the markup itself. Selectors may apply to all elements of a specific type, or to elements specified by attribute or identified by ID or class.

Properties

A CSS property is a characteristic of an HTML element that can be changed, such as its color, border, or background. Each property has a set of possible values. Some properties can affect any type of element, and others apply only to particular groups of elements.

Values

Values are assigned to properties, and can be keywords or numerical values. For example, the property "color" could have the value "red" or "#FF0000".

CSS Box Model

The CSS box model is a rectangular layout paradigm for HTML elements that consists of the following: content, padding, border, and margin. This model allows designers to manipulate the spacing, borders and padding around elements.

Layouts

CSS layouts help to arrange elements on the screen and can be of different types like fixed, fluid or responsive. The layout technique is chosen based on the design requirements of a webpage.

CSS Frameworks

A CSS framework is a pre-prepared library that is meant to allow for easier, more standards-compliant styling of web pages using the Cascading Style Sheets language. Some popular CSS frameworks are Bootstrap, Foundation, and Materialize.

CSS Preprocessors

CSS preprocessors are scripting languages that extend the default capabilities of CSS. They enable us to use logic in our CSS code, such as variables, nesting, inheritance, mixins, functions, and mathematical operations. Some popular CSS preprocessors include Sass, LESS and Stylus.

Future of CSS

The future of CSS is likely to include more advanced features, as the language continues to evolve. New proposals by the W3C, such as CSS Grid Layout and CSS Variables, are promising enhancements that provide more flexibility and control in the design process.

See Also

Categories