CSS Definition, Syntax and Usage – What is CSS


CSS (Cascading Style Sheets) is a web technology used to format HTML elements. The syntax of this coding technique, which is very simple to use, consists of a selector and the brackets {} that define the properties of this selector. The syntax is shown as an example below.

body {

Cascading Style Sheets is a markup language. The distinguishing feature of it from other programming languages is that it is not a standalone function.

Defining Cascading Style Sheets in HTML Page

CSS can be defined on a web page in multiple ways. These are the main ones;

Invoke The CSS File Externally With The <link> Element

Like its name, the extension of style files is .css. We can store our CSS code in a style file and then apply it to our page using the <link> element. Used as:

<link href="style.css" rel="stylesheet">

As you can see here, we need to place the style file between the <head> </head> tags.

Apply The CSS Code To The Page With The <style> Element

In this usage, you can place the same CSS code this time between the <style> </ style> tags on the page you want to use. Usage is as follows:

<style type="text/css">
body {
color: yellow;

Using Element with style=”” Directive

This type of use allows you to apply the CSS code directly on the element. So you can format elements without having to call any file. Example usage is as follows:

<div style="display: block; padding: 10px">


Commens on Cascading Style Sheets

The description lines are written between /* … */. Below is an example of using comment lines.

body {
    margin: 0;
    padding: 0;
    /* This is a single-line comment */
    text-align: center;
    color: red;

/* This is
a multi-line
comment */