Day 4 Home

Syntax

CSS works by associating rules with HTML elements. These rules govern how the content of specified elements should be displayed. A CSS rule contains two parts: a selector and a declaration. Here is an example in which we change the font-size of all paragraph elements on our page:

 p { font-size: 24 px;} 

In the previous example, p (or paragraph) is the selector and font-size: 24 px; is the declaration (thing we want to do to paragraphs). The declaration goes inside left and right braces (often refered to as curly brackets) and each is made up of two parts: a property and a value, separated by a colon. You can specify several properties in one declaration, each separated by a semi-colon.

Properties indicate the aspects of the element you want to change. For example, color, font, width, height and border. Values specify the settings you want to use for the chosen properties. For example, if you want to specify a font-familiy (type of font) property then the value is the font you want the text in these elements is written as follows:

 h1 { font-family: Arial;} 
How to Add CSS