Author: Matt Blanco

Last Updated: 26 December, 2021

CSS stands for Cascading Style Sheets and it’s the technology that allows the structure of an HTML document to look good and bring a prototype’s design into life.

Using CSS

There are three main ways to implement CSS code into a webpage:

  1. Linking to an external CSS file (Preferred)

    <head>
    	<link rel="stylesheet" type="text/css" href="style.css"/>
    </head>
    
  2. Directly inside an element using the style attribute

    1. ex: <div style=”background-color: blue; text-align: center”>
  3. Using the <style> element inside the <head>

    <head>
    	<style>
    			p {
    				color: red;
            ...
    			}
    	</style>
    <head>
    

Syntax

h1 {
	color: blue;
}

In CSS the h1 is the selector and indicates what elements will by styled (there are many different ways to select HTML elements that will be discussed further on).

The color is one of many different CSS properties that can be used to style elements (list of all the different properties that can be used).

The blue is the value of the CSS property. Each property has it’s own values that can be applied to it.

Selectors

As mentioned above, selectors are used to locate the HTML elements you want to style. There are five different categories for selectors:

Simple selectors

Select elements based on name, id, class

Element Selector: p { ... }

Id Selector: #idName{ ... }

Class Selector: .className{ ... }

Combinator selectors