CSS Basics
CSS Basics
1
What is CSS
2
CSS Syntax
3
How to add CSS
4
Example of External CSS
• External styles are defined
<!DOCTYPE html> within the <link> element,
<html> inside the <head> section of
<head> an HTML page
<link rel="stylesheet" href="my
• An external style sheet can
style.css">
be written in any text editor,
</head>
and must be saved with
<body>
a .css extension.
<h1>heading</h1> • With an external style
<p>paragraph.</p> sheet, you can change the
look of an entire website by
</body> changing just one file
</html>
5
Example of External CSS
h1 {
color: navy;
margin-left: 20px;
}
6
Example of Internal CSS
<!DOCTYPE html>
<html>
<head> • An internal style sheet
<style>
body { may be used if one
}
background-color: pink;
single HTML page has a
h1 { unique style.
color: blue;
margin-left: 40px; • Internal styles are
}
</style> defined within the
</head>
<body>
<style> element, inside
<h1>heading</h1> the <head> section of
<p>paragraph.</p>
</body> an HTML page
</html>
7
Example of Inline CSS
10
Multiple Style Sheets
<head>
<link rel="stylesheet“ href="mystyle.css">
<style>
h1 {
color: blue;
}
</style>
</head>
11
Multiple Style Sheets
12
Multiple Style Sheets
13
Multiple Style Sheets
14
15