How to use CSS selectors

CSS selectors are the heart and soul of CSS. They define which HTML elements you are going to be manipulating with CSS code. The CSS syntax consists of a set of rules. These rules have 3 parts: a selector, a property, and a value.

SYNTAX:

SELECTOR { PROPERTY: VALUE }

Selector:Represents the HTML element you want to style (eg:body)

Property: Represents CSS element you want to manipulate(eg:background color)

Value: Represents value of the specified property(eg:”#FFFF00″)

EXAMPLE:

A CSS declaration always ends with a semicolon, and declaration groups are surrounded by curly brackets:


p

{

color:blue;

text-align:left;

}

CSS COMMENTS

Comments are the simple explain about your code, and it help you to edit the source codeĀ  later.

A CSS comments begins and ends with /*……*/ like this,

EXAMPLE:


/*Code to align the text in left and change the color of text to blue*/

p

{

color:blue;

text-align:left;

}

Posted in CSS Tagged with: