CSS styles can be applied using three different ways:
CSS styles apply order:
In a HTML page, styles are applied (ie., System priority order) in the following way
Example: Attach external style sheet to HTML page.
CSS file (stylescore.css) contents.
body {width:200px;height:100px;border:double}
div { color:blue;}
<!DOCTYPE html />
<html>
<head>
<link rel="stylesheet" href="stylescore.css"/>
<title>External Style Sheet</title>
</head>
<body>
<div>First line</div>
<div>Second line</div>
<div>Third line</div>
</body>
</html>
Result:
In the above example,
Example: Attach Internal and Inline CSS styles to HTML elements.
a)
<style type="text/css">
div {
color:green;
}
b)
<div style="color:red">Third line</div>
<!DOCTYPE html />
<html>
<head>
<title>Internal and Inline Style Sheet</title>
<style type="text/css">
div {
color:green;
}
</style>
</head>
<body>
<div>First line</div>
<div>Second line</div>
<div style="color:red">Third line</div>
</body>
</html>
Result:
In the above example,