Modern Front End Tech logo

modern front end tech

learn css for free

In this chapter, you will learn how to write CSS code to style HTML elements. You will learn about selectors, properties, and values, and how to use them to create beautiful web pages.

Lesson 2

How to Write CSS Code

CSS code consists of selectors, properties, and values working together to style HTML elements.

Core idea

Parts of CSS Code

CSS code uses selectors to choose elements, properties to define what to change, and values to set the specific style.

parts of css code

credit: bikegremlin.com for this image

Selectors

Selectors Target HTML Elements

Selectors are used to target HTML elements that you want to style. There are different types of selectors, including element selectors, class selectors, and ID selectors.

Properties

Properties Define Styles

Properties are used to define the styles that you want to apply to the selected elements. There are many different properties available in CSS, including color, font-size, margin, padding, and more.

Values

Values Set Property Settings

Values are used to specify the settings for the properties. For example, if you want to set the color of an element to red, you would use the property "color" and the value "red".

Checkpoint

Key CSS Terms to Know

our youtube channel