0% completed
CSS syntax defines how CSS rules are written and applied to HTML elements. Understanding the structure is crucial to effectively style your web pages.
A CSS rule is made up of the following parts:
{}
.:
.Syntax:
selector { property: value; property: value; }
p { color: blue; font-size: 16px; }
p
targets all <p>
(paragraph) elements.color
and font-size
are the properties.blue
and 16px
are the corresponding values.button { background-color: green; color: white; border: none; padding: 10px 20px; }
<button>
elements.background-color
: Sets the button's background to green.color
: Makes the text white.border
: Removes the border.padding
: Adds space inside the button.;
. This separates one declaration from the next.{}
: The declaration block is enclosed in curly braces.color
or COLOR
works). However, values like font names can be case-sensitive.This lesson introduced the syntax of CSS with examples and explanations.
.....
.....
.....