Cascading in CSS -Notes Lyst8633
Cascading in CSS -Notes Lyst8633
CSS - Day 2
Agenda
▪ EXTERNAL CSS
▪ Cascading in CSS
External CSS:
External CSS contains separate CSS file which contains only style
property with the help of tag attributes. CSS property written in a
separate file with .css extension and should be linked to the HTML
document using link tag. The advantage of external stylesheets is that
it can be created once and the rules applied to multiple web pages. If
we need to make widespread changes to your site design, you can make
a single change in the stylesheet and it will be applied to all linked
pages, saving time and effort as it prevents you from having to make
many code changes in each page.
Let us now understand with an example how to make use of external
css. Assume we have 3 html files index.html, index1.html, index2.html
and we have to apply same styling for all these files then the concept of
External css comes where styling should be done in one CSS file and
linked to all html files.
index1.html
style.css
index1.html
style.css
index.css
As we can see in the above example all three ways of css is applied to
h1 tag and clearly we can see in the output by default inline css has
been given higher precedence compared to internal and external css.
Now we will see if we remove inline css and only internal and external
css is applied which will get higher precedence.