Chapter One Css
Chapter One Css
Chapter One Css
terfaces for web applications and user interfaces for many mobile applications.
CSS
Not just a language all its own, CSS is a part of HTML.
The first version of HTML to include CSS was HTML 4.0
CSS was added to HTML to solve a particular problem - the problem of the cont
ent of HTML documents not being separated from the layout of the documents.
Selector: Selector indicates the HTML element you want to style. It could be
any tag like <h1>, <title> etc.
Declaration Block: The declaration block can contain one or more
declarations separated by a semicolon.
For the above example, there are two declarations:
Color: blue;
Font-size: 12px;
01/23/24 prepared by Alebel Ayalneh
Each declaration contains a property name and value, separated by a colon.
Property: A Property is a type of attribute of HTML element. It could be color, border etc.
Value: Values are assigned to CSS properties. In the above example, value "yellow" is
assigned to color property.
1.1.4 Style Rule Locations
index.html
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
<html>
<head>
<link rel=“stylesheet” type=“text/css” href=“mystyles.css” />
<style type=“text/css”>
h1 { color: Red; }
</style>
</head>
<body>
<h1 style=“color:red;”>A Sample Heading</h1> ...
Embedded styles affect only the tags on the page they are embedded in.
<style type="text/css">
p { color: #00f; } </style>
2. External - Placed in a separate file.
3. Inline - Placed inside a tag it will affect.
Inline styles are styles that are written directly in the tag on the document.
Inline styles affect only the tag they are applied to.
<a href="" style="text-decoration: none;">
If a value is more than one word, put quotes around it.
Example: body{
background-color: gray;
color: yellow;
margin-top: 0; }
29
Grouping styles
You can specify that a group of tags will have the same styles by grouping them
together.
{ color: blue;
font-family: courier; }
In this example, all text declared with the tags <p>, <h1>, <h2>, <h3>, and <h4>