└>Lesson 2: CSS Syntax
A piece of CSS code is made up with 3 parts, a selector, a property, and a value for that property. Values and properties are seperated by a colon, and ended with a semicolon and are enclosed by curly braces after the selector:
selector {
property: value;
}
example:
div { width: 50px; }
Selectors can be grouped by seperating them with a comma:
selector1,selector2,selector3,etc... { property: value; }
example:
h1,h2,h3 {
color: red; }
Comments in CSS
Comments are quite easy in css, you can place a comment between
/* and */ for example:
body {
background-color: red; /* this makes the background red */
}
That should have been simple enough for you I hope, now head to Lesson 3, where you can learn about how to use Selectors.