Custom Search

Monday, July 7, 2008

About Selector in CSS

Once of primary advantages of CSS is its ability to easily apply set of style to all elements of the same type.like example, by editing a single line of CSS, we can change background of all our heading. CSS has rule that divide become 2 parts : a selector, which tells the browser which element(s) will be affected by the rule; and a declaration block, which determines which properties of the element will be modified.

Example :


H1 { color : red }


H1 is a selector

color :red is a declaration block which is color is property and red is value


The selector, shown on the left side of the rule, defines which piece of the document will be affected. in this case, all element that contain H1 has become red.

Selector can also be grouping of selector, if we want the same style to apply to multiple elements. in that case we will want to use more than one selector or apply more than one style to an element or group of elements.

example :

h1,p { color : red }

in above example, elements h1 and paragraph have red text. By placing the h1 and p selectors on the left side of the rule and separating them with a comma, we have defined a rule where the style on the right (color: red;) applies to the elements referenced by both selectors. The comma tells the browser that there are two different selectors involved in the rule. Leaving out the comma would give the rule a completely different meaning.


about selector will be continue in the next post……

No comments:

Free Traffic

 Join My Community at MyBloglog! Blog Flux Directory 

Web Developement Blogs - BlogCatalog Blog Directory web development blog  Internet Blogs - Blog Top Sites 

Blog Directory 

Click Here for Free Traffic!

Link2Communion.com