The appearance (color, size, and position among other things) of HTML elements can be styled through Cascading Style Sheets or CSS. Style sheets are lists of rules which tell the browser how to display certain elements of a web page. The idea behind CSS is to separate the content of a web page from the presentation. If the appearance of a web page is formatted with CSS, then the entire web page can be reformatted easily without having to modify the content. This allows content to be reused and redisplayed on different devices.
CSS can be included in a web page in three different ways. First, the CSS can be placed in an external file separate from the HTML file. To include a style file style.css in an HTML file, include this line in the head section of the HTML file:
<link rel="stylesheet" type="text/css" href="quick.css">
CSS can also be included in the head section of an HTML file. Doing so would involve using code such as this in the head section:
<style type="text/css"> ...STYLE RULES... </style>
Finally, CSS can be included inline within the HTML content of a web page. This defeats the purpose of separating content and presentation. It also prevents the ability of using the same CSS to style multiple HTML elements, but sometimes it is a quick means to an end. Styling a div with inline CSS would look something like:
<div style="...STYLE RULES..."> DIV CONTENTS </div>
table {
...STYLE RULES HERE WILL APPLY TO ALL TABLES...
}
p {
...STYLE RULES HERE WILL APPLY TO ALL PARAGRAPHS...
}
h1 {
...STYLE RULES HERE WILL APPLY TO ALL H1 HEADERS...
}
#titlebar {
...STYLE RULES HERE WILL APPLY TO THE ELEMENTS WITH ID titlebar...
}
#menubar {
...STYLE RULES HERE WILL APPLY TO THE ELEMENTS WITH ID menubar...
}
div.urgent {
...RULES FOR DIVS WITH CLASS urgent...
}
p.indented {
...RULES FOR PARAGRAPHS WITH CLASS indented...
}
...INSIDE THE HTML...
<div class="urgent"> DIV CONTENT </div>
...
<p class="indented"> P CONTENT </div>
<div class="style1"> I am a div. I am a div. I am a div. I am a div. I am a div. I am a div. I am a div. I am a div. I am a div. I am a div. </div>
IN THE HEAD...
<style type="text/css">
div.style1 {
background: steelblue;
}
</style>
IN THE HEAD...
<style type="text/css">
div.style1 {
background: steelblue;
color: white;
}
</style>
IN THE HEAD...
<style type="text/css">
div.style1 {
background: steelblue;
color: white;
font: italic 20px "Times New Roman";
}
</style>
IN THE HEAD...
<style type="text/css">
div.style1 {
background: steelblue;
color: white;
font-family: "Times New Roman";
font-type: italic;
font-size: 20px;
}
</style>
IN THE HEAD...
<style type="text/css">
div.style1 {
background: steelblue;
color: white;
font: italic 20px times new roman;
width: 200px;
height: 100px;
}
</style>
IN THE HEAD...
<style type="text/css">
div.style1 {
background: steelblue;
color: white;
font: italic 20px times new roman;
width: 25%;
height: 100px;
}
</style>
IN THE HEAD...
<style type="text/css">
div.style1 {
background: steelblue;
color: white;
font: italic 20px times new roman;
width: 200px;
height: 100px;
overflow: auto;
}
</style>
IN THE HEAD...
<style type="text/css">
div.style1 {
background: steelblue;
color: white;
font: italic 20px times new roman;
width: 200px;
height: 130px;
border-style: solid;
border-color: lightblue;
border-width: 5px;
}
</style>
IN THE HEAD...
<style type="text/css">
div.style1 {
background: steelblue;
color: white;
font: italic 20px times new roman;
width: 200px;
height: 130px;
border: 5px solid lightblue;
}
</style>
IN THE HEAD...
<style type="text/css">
div.style1 {
background: steelblue;
color: white;
font: italic 20px times new roman;
width: 200px;
height: 130px;
border: 5px solid lightblue;
border-radius: 20px;
}
</style>
IN THE HEAD...
<style type="text/css">
div.style1 {
background: steelblue;
color: white;
font: italic 20px times new roman;
width: 200px;
height: 130px;
border: 5px solid lightblue;
border-radius: 20px;
padding: 10px;
}
</style>
IN THE HEAD...
<style type="text/css">
div.style1 {
background: steelblue;
color: white;
font: italic 20px times new roman;
width: 200px;
height: 130px;
border: 5px solid lightblue;
border-radius: 20px;
padding: 10px;
margin: 10px;
}
</style>

IN HEAD...
<style type="text/css">
div.blue {
background: lightblue;
width: 200px;
height: 200px;
display: block;
}
div.red {
background: red;
width: 200px;
height: 200px;
display: block;
}
</style>
...IN BODY...
<div class="blue"> Blue div. Blue div. Blue div. Blue div. Blue div. Blue div. </div>
<div class="red"> Red div. Red div. Red div. Red div. Red div. Red div. </div>
IN HEAD...
<style type="text/css">
div.blue {
background: lightblue;
width: 200px;
height: 200px;
display: inline-block;
}
div.red {
background: red;
width: 200px;
height: 200px;
display: inline-block;
}
</style>
...IN BODY...
<div class="blue"> Blue div. Blue div. Blue div. Blue div. Blue div. Blue div. </div>
<div class="red"> Red div. Red div. Red div. Red div. Red div. Red div. </div>
IN HEAD...
<style type="text/css">
div.blue {
background: lightblue;
width: 200px;
height: 200px;
display: inline;
}
div.red {
background: red;
width: 200px;
height: 200px;
display: inline;
}
</style>
...IN BODY...
<div class="blue"> Blue div. Blue div. Blue div. Blue div. Blue div. Blue div. </div>
<div class="red"> Red div. Red div. Red div. Red div. Red div. Red div. </div>
IN HEAD...
<style type="text/css">
div.blue {
background: lightblue;
width: 200px;
height: 200px;
display: inline;
}
div.red {
background: red;
width: 200px;
height: 200px;
display: inline-block;
}
</style>
...IN BODY...
<div class="blue"> Blue div. Blue div. Blue div. Blue div. Blue div. Blue div. </div>
<div class="red"> Red div. Red div. Red div. Red div. Red div. Red div. </div>