What is CSS?

CSS (Cascading Style Sheets) is a language that is used to define the appearance and layout of websites. CSS is used to design elements on a website, such as text, images, buttons and forms.

An example of CSS code is:

h1 {
  colour: blue;
  font-size: 24px;
  text-align: centre;

This code is used to define the design of headings (h1 elements) on a web page. The properties "colour", "font-size" and "text-align" are used to define the colour, font size and alignment of the heading.

Another example of CSS code is:

button {
  background-color: green;
  colour: white;
  padding: 10px 20px;
  border-radius: 5px;

This code is used to define the design of buttons on a website. The properties "background-color", "colour" and "padding" are used to define the background colour, text colour and spacing within the button. The "border-radius" property is used to round off the corners of the button.

Overall, CSS is an important tool for designing and embellishing websites. It enables developers to easily change and customise the visual design of websites.

In CSS, the formatting for the various elements of the HTML are defined. Selectors are, for example, HTML elements such as body, p (paragraph), div (container element).

Classes are selectors that can be assigned to the various elements in HTML, similar to style sheets in Microsoft Word, for example.

In HTML, for example, this is written like this:

<p class="red-text">This text is red.</p>

This is what it looks like in the browser:

This text is red.

The project CSS Zen Garden impressively demonstrates how the same HTML document can be designed completely differently using only CSS.

The different designs:

More: CSS3

Related Glossare