There are three ways of inserting a style sheet:
- External style sheet
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
- Internal style sheet
<head>
<style>
body {
background-color: linen;
}
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>
<style>
body {
background-color: linen;
}
h1 {
color: maroon;
margin-left: 40px;
}
</style>
</head>
- Inline style
<h1 style="color:blue;margin-left:30px;">This is a heading.</h1>
If some properties have been set for the same selector in different style sheets, the values will be inherited from the more specific style sheet.
What style will be used when there is more than one style specified for an HTML element?
Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by the following rules, where number four has the highest priority:
- Browser default
- External style sheet
- Internal style sheet (in the head section)
- Inline style (inside an HTML element)
Note: If the link to the external style sheet is placed after the internal style sheet in HTML <head>, the external style sheet will override the internal style sheet! |
Comments
Post a Comment