Account
Categories

How to Add CSS to HTML


Definition:

As the name suggests, it is used to select HTML elements based on your website's needs.

Once selected, you can apply different properties with values.

For example, if you select a <p> (paragraph) element and want its text color to be red and font size to be 20px, then you can set these using CSS properties.

Syntax:

selector {
property: value;
}

Example:

p {
color: blue;
font-size: 18px;
background-color: #f0f0f0;
padding: 10px;
}

Output:

The paragraph will be blue text, bigger size (18px), light grey background (#f0f0f0), and space around it (10px padding).