Introduction

CSS (an abbreviation of Cascading Style Sheets) is the language that we use to style an HTML file, and tell the browser how should it render the elements on the page.

Browser is often called user agent so user agent stylessheets mean the default styles provided by the browser.

CSS let us move everything presentation-related from the HTML to the CSS, so that HTML could get back being the format that defines the structure of the document, rather than how things should look in the browser.

We don’t have official release numbers for CSS any more now, but the CSS Working Group releases a “snapshot” of the modules that are currently considered stable and ready to be included in browsers.

Syntax of CSS

Each rule is composed by 2 parts:

selector(s) {
	property: value;
}
/ * This is a comment in CSS * /

Each property-value pair must end with a semicolon( ; ), and the value is assigned to the property by colon( : ).

Ways to add CSS in a html script

Inline (using style attribute): CSS is added to the elements directly using the style attributes.

eg. <p style= “color: red; ”>

Internal (using style tag): CSS is kept inside the head tags in <style> tags.

External (using css file and link tag): CSS is kept separately inside a .css style sheet.

It involves two steps-

  1. Write the CSS in .css file.
  2. Include that CSS file to Markup. <link rel=“stylesheet” href=“file.css”>