7 examples of CSS Declaration

Photo by Dean Pugh on Unsplash

A CSS declaration consists of a property and a value separated by a colon (:), followed by a semicolon (;) to conclude it. Below are 7 examples of CSS declarations:


1. Color Declaration
color: blue;


2. Font Size Declaration
font-size: 16px;


3. Background Color Declaration
background-color: #f0f0f0;


4. 3Margin Declaration
margin: 20px;


5. Padding Declaration
padding: 10px;


6. Border Declaration
border: 1px solid black;


7. Display Declaration
display: flex;


Each of these declarations can be used inside a CSS rule set to style HTML elements. For example:
p {
    color: blue;
    font-size: 16px;
    margin: 20px;
}


Comments