CSS 2
CSS 2
(CSS)
Cascading Style Sheets (CSS) is a style sheet language used for describing
the presentation of a document written in a markup language like HTML
Inline CSS
Within the tags
<html>
<head>
<title>Example</title>
</head>
<body style="background-color: #FF0000;">
<p>This is a red page</p>
</body>
</html>
Internal CSS
Within HTML using style tag
<html>
<head>
<title>Example</title>
<style type="text/css">
body {background-color: #FF0000;}
</style>
</head>
<body>
<p>This is a red page</p>
</body>
</html>
External CSS
Separated file: e.g. style.css
body {
background-color: #FFCC66;
background-image: url("butterfly.gif");
background-repeat: no-repeat;
background-attachment: fixed;
background-position: right bottom;
}
h1 {
color: #990000;
background-color: #FC9804;
}
HTML page
<html>
<head>
<title>My document</title>
<link rel="stylesheet" type="text/css" href=“style2020.css">
</head>
<body>
<h1>My first stylesheet</h1>
</body>
</html>
background-attachment
CSS Background Properties
Property Description
background Sets all the background properties in one
declaration
background-attachment Sets whether a background image is fixed or
scrolls with the rest of the page
background-color Sets the background color of an element
background-image Sets the background image for an element
background-position Sets the starting position of a background image
background-image: url(images.png);
p{background-image: url(“images/bg.jpg”);}
Example
body
{
background-image:url(‘image.png');
background-repeat:repeat-x;
Background-position:center,center;
}
DIV Tag
The <div> tag is also known as the division element. It is a
generic block-level element. These are the elements that start from
a new line. They are widely used to divide the content on the page
into different blocks.
<div id="navigation">
<ul>
<li><a href="index.html" title="Go Home">Home</a></li>
<li><a href="about.html" title="Learn more about us">About</a></li>
<li><a href="contact.html" title="Contact us">Contact</a></li>
</ul>
</div>
Span Tag
• Font-family:
p{
font-style: italic;
font-weight: bold;
font-size: 30px;
font-family: arial, sans-serif;
}