The CSS syntax is made up of three parts
selector {property: value;}- Selector
- The selector is what is used to call the style for a particular use. You can name these anything you like with one exception. It must start with an alpha character and not a number. Numbers can be used but the first digit must be a letter followed by more letters, digits, or hyphens. The letters are restricted to A-Z and a-z. Blank spaces are not allowed.
- Property
- This is where you place the element you want to style. This is then followed with the colon symbol.
- Value
- This is where you place how you want the element styled or action that should take place. Follow this with the semi-colon symbol.
The property and the value must be enclosed inside brackets {}.
There are two types of selectors, id and class
An id is identified by the use of the number # symbol. And a class is identified by the use of a dot.
An id # can only be used once per page and is beneficial in helping keep your layout properly structured. In addition it can be used as a link identifier. Use an id for those elements that you only want displayed once such as the top section, main content or footer sections.
The class selector can be used as many times as you want on a single page. The benefit here is that you can set styles to different elements that are not contained inside the same div container.
How to assign a selector as an ID or a class
To assign a selector as an id place the number symbol in front of the selector name.
To assign a selector as a class place a dot in front of the selector name.