Write the opening tags for:
A link
An unordered list
An image
A paragraph
Write the opening tags for:
A link
An unordered list
An image
A paragraph
<a href="">
<ul>
<img src="" alt="">
<p>
Learn how to write CSS
Learn how to link CSS to a HTML page
CSS or Cascading Style Sheets add style to a webpage
Without CSS we just have HTML on our webpage – so no colour, no borders and just no fancy stuff
HTML on it’s own is just boring text on a white background!
<html>
<head>
<title>My webpage</title>
</head>
<body>
<p>Hello everyone!</p>
</body>
</html>
<html>
<head>
<title>My webpage</title>
<style>
p {
color : green;
}
</style>
</head>
<body>
<p>Hello everyone!</p>
</body>
</html>
A CSS file is made up of rules.
Image copyright jamiebalfour.scot
p {
color: green;
}
What we want to style
p {
color: green;
}
How we want to style it
p {
color: green;
}
Don't forget the semi-colon after each property and value pair
This is an example of a CSS rule
p {
color: green;
font-size: 20pt;
}
This is an example of a CSS rule
p {
color: green;
font-size: 20pt;
}
body {
background-color: gray
}
This is an example of a CSS rule
h1 {
background-color: red;
color: blue;
border: 2px green solid;
font-size: 14pt;
}
This is an example of a CSS rule
head {
background: green;
}
<html>
<head>
<title>My website</title>
<style>
h1 {
background: green;
}
</style>
</head>
<body>
<h1>I’m green!</h1>
</body>
</html>
<html>
<head>
<title>My website</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<p class="green_class">I’m green!</p>
</body>
</html>
<html>
<head>
<title>My website</title>
</head>
<body>
<p style="color:green">I’m green!</p>
</body>
</html>
Disadvantages
Advantages
Disadvantages
<html>
<head>
<title>My website</title>
<style>
h1 {
background: green;
}
</style>
</head>
<body>
<h1>I’m green!</h1>
</body>
</html>
p {
color : green;
}
<html>
<head>
<title>My website</title>
<style>
.green_background {
background: green;
}
</style>
</head>
<body>
<h1 class="green_background">I’m green!</h1>
<p class="green_background">This is green</p>
<p>But this is not green</p>
</body>
</html>
<html>
<head>
<title>My website</title>
<style>
#big_text {
font-size:30px;
}
</style>
</head>
<body>
<h1>Welcome</h1>
<p id="big_text">This text is bigger</p>
<p>This is regular text</p>
</body>
</html>
DEMO
p {
font-family : Garamond, Georgia, "Times New Roman";
font-size : 12pt;
}
p {
color : green;
}
p {
text-align : center;
text-align : left;
text-align : right;
text-align : justify;
}
p {
background-color : green;
}
body {
background-color : red;
}
Apply a filter: