KnowledgeBoat Logo
|

Computer Applications

What does Cascading imply in CSS? Support your answer with an example.

CSS

11 Likes

Answer

Cascading means the hierarchical order in which different style sheet types are arranged so that the latest style sheet takes the precedence on the earlier ones. Consider the example given below:

<HTML>
<HEAD>
<STYLE> P{Color: red} </STYLE>
<STYLE> P{Color: blue} </STYLE>
<STYLE> P{Color:green} </STYLE>
</HEAD> 
<BODY Bgcolor = "Lightyellow">
<H1> Tiger Reserves in lndia </H1>
<P> Jim Corbett Tiger Reserve, Uttarakhand </P>
<P> Ranthambore Tiger Reserve, Rajasthan </P>
<P> Sunderban Tiger Reserve, West Bengal </P>
<P> Bandhavgarh National Park, Madhya Pradesh </P>
<P> Sariska Tiger Reserve, Rajasthan </P>
</BODY>
</HTML>

Here, the first definition specifying the <P> colour as red precedes the second definition, which defines the blue colour for <P>, and this, in turn, precedes the third definition, which specifies the green colour for <P>. The definition at the bottom will take precedence, and the paragraph will appear in green colour.

Answered By

3 Likes


Related Questions