Grouping and Nesting

Suppose we need to have two classes with almost exactly same style but varying in their background. So, we dont need to write the whole style attributes again and again. Infact, this can simply be done by grouping the classes and consider the different values separately. Here is an example :-


This is some text in para 1

This is some text in para 2

So, in the above example we dont need to write the matching stuffs for the various classes again and again. This property is going to be very useful when we will start developing our website that will contain a number of classes with slightly varying styles.


As we have discussed earlier that by providing ids to any of the tags, we can specify attributes for that tag. However providing too much ids may be confusing and we might get confused sometime later when we wisg to revisit our code to make some modifications. So, there comes the need of nesting.

As the name suggests it is basically about selecting child of parent tag and assigning them style attributes. We select a particular div using the selector method as discussed earlier and then select particular tags in that element. Hope an example will make things clear.


I am blue

I am of usual color

This is of usual color

Lets see some other stuffs to decorate our tags.

Member Login

Member Login

Not a Member? Sign Up!

Login to comment

Be the first to comment on this topic


<<< Wanna review

Continue >>>