Common CSS Properties
CSS properties allow you to control the appearance and layout of HTML elements:
- color: Sets the text color.
- background-color: Sets the background color.
- font-size: Sets the size of the text.
- margin: Sets the space outside an element.
- padding: Sets the space inside an element.
- border: Sets the border around an element.
- width: Sets the width of an element.
- height: Sets the height of an element.
Example: CSS Properties
/* Example */
div {
color: white;
background-color: black;
font-size: 16px;
margin: 10px;
padding: 20px;
border: 2px solid red;
width: 300px;
height: 150px;
}
This example demonstrates how to use various CSS properties to style a div element.
Practice
Try experimenting with CSS properties:
- Change the
colorandbackground-colorof elements. - Adjust
marginandpaddingvalues to see their effects. - Set
widthandheightfor different elements.
Continue Learning
Quick Check
Which CSS property sets the space inside an element?