What is cascading order?
Cascading order is a sorting system consisting of rules
by which declarations are sorted out so that there are
not conflicts as to which declaration is to influence
the presentation. The sorting begins with rule no 1. If
a match is found the search is over. If there is no
match under rule no 1 the search continues under rule no
2 and so on.
1. Find all declarations that apply to a specific
selector/property and Declare the specified style if the
selector matches the element if there isn't any Let the
element inherit its parent property if there isn't any
Use initial value
2. Sort by weight (! important) Increased weight take
precedence over normal weight
3. Sort by origin Rules with normal weight declared in
author's style sheet will override rules with normal
weight declared in user's personal style sheets Rules
with increased weight declared in user's personal style
sheet will override rules with normal weight declared in
author's style sheet Rules with increased weight
declared in author's style sheet will override rules
with increased weight declared in user's personal style
sheets Author's and user's rules will override UA's
default style sheet.
4. Sort by selector's specificity More specific selector
will override less specific one: ID-selector (most
specific), followed by Classified contextual selectors
(TABLE P EM.fot) Class selectors (EM.fot) Contextual
selectors - the "lower down" the more weight, (TABLE P
EM), (TABLE P EM STRONG) - STRONG has more weight than
EM.
5. Sort by order specified If two rules have the same
weight, the latter specified overrides ones specified
earlier. Style sheets are sorted out as follows: The
STYLE attribute (inline style) overrides all other
styles The Style element (embedded style) overrides
linked and imported sheets The LINK element (external
style) overrides imported style The @import statement -
imported style sheets also cascade with each other in
the same order as they are imported
Why shouldn't I use fixed sized fonts ?
Only in very rare situations we will find users that
have a "calibrated" rendering device that shows fixed
font sizes correct. This tells us that we can never know
the real size of a font when it's rendered on the user
end. Other people may find your choice of font size
uncomfortable. A surprisingly large number of people
have vision problems and require larger text than the
average. Other people have good eyesight and prefer the
advantage of more text on the screen that a smaller font
size allows. What is comfortable to you on your system
may be uncomfortable to someone else. Browsers have a
default size for fonts. If a user finds this
inappropriate, they can change it to something they
prefer. You can never assume that your choice is better
for them. So, leave the font size alone for the majority
of your text. If you wish to change it in specific
places (say smaller text for a copyright notice at the
bottom of page), use relative units so that the size
will stay in relationship to what the user may have
selected already. Remember, if people find your text
uncomfortable, they will not bother struggling with your
web site. Very few (if any) web sites are important
enough to the average user to justify fighting with the
author's idea of what is best.
How do you make a whole div into a link?
You can't put 'a' tags around a div, but you can do this
with javascript :
HTML
<div onclick="javascript:location='http://bonrouge.com'"
id="mydiv">
... stuff goes here ...
</div>
If you want to use an empty div with a background image
as a link instead of putting your image into the html,
you can do something like this:
CSS
#empty {
background-image:url(wine.jpg);
width:50px;
height:50px;
margin:auto;
}
#empty a {
display:block;
height:50px;
}
* html #empty a {
display:inline-block;
}
HTML
<div id="empty"><a href="#n"></a></div>
How do I have links of different colors on the same
page?
Recommending people to use classes in their 'a' tags
like this :
CSS
a.red {
color:red;
}
a.blue {
color:blue;
}
HTML
<a href="#" class="red">A red link</a>
<a href="#" class="blue">A blue link</a>
This is a valid way to do it, but usually, this isn't
what a page looks like - two links next to each other
with different colours - it's usually something like a
menu with one kind of link and main body text or another
menu with different links. In this (normal) situation,
To go higher up the cascade to style the links.
Something like this :
CSS
a {
color:red;
}
#menu a {
color:blue;
}
HTML
<ul id="menu">
<li><a href="#">A red link</a></li>
<li><a href="#">A red link</a></li>
</ul>
<div id="content">
<p>There's <a href="#">a blue link</a> here.</p>
</div>
What is shorthand property?
Shorthand property is a property made up of individual
properties that have a common "addressee". For example
properties: font-weight, font-style, font-variant,
font-size, font-family, refer to the font. To reduce the
size of style sheets and also save some keystrokes as
well as bandwidth they can all be specified as one
shorthand property font, e.g.:
H1 {font-weight: bold;
font-style: italic;
font-variant: small-caps;
font-size: 160%;
font-family: serif}
can be all shorthanded to a space separated list:
H1 {font: bold italic small-caps 160% serif}
Note: To make things even simpler the line-height
property can be specified together with the font-size
property:
H1 {font: bold italic small-caps 160%/170% serif}
How to use CSS building a standards based HTML template?
It should:
1. Contain: header, navigation, content, footer
2. Use well-structured HTML
3. Be error-free and encourage good coding
Let’s start with number one there:
HTML document split up in four parts all with different
meaning, use the
-tag. Div is short for “division” and isn’t header,
navigation and so on ...
!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type"
content="text/html; charset=ISO-8859-1">
<title>Your own page title</title>
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body>
<div id="header">
<h1>The name of this page</h1>
</div>
<div id="navigation">
<h2>Navigation</h2>
<ul>
<li><a href="first.html">First</a></li>
<li><a href="second.html">Second</a></li>
<li><a href="third.html">Third</a></li>
</ul>
</div>
<div id="content">
<h2>Content</h2>
<p>Some sample content, add your own here</p>
</div>
<div id="footer">
<p>This page is written by [Your name] and builds
n a <a href="http://friendlybit.com">
Friendlybit template</a>.</p>
</div>
</body>
</html>
body {
background-color: Green;
}
div {
border: 3px solid Black;
padding: 7px;
width: 600px;
}
h1, h2, h3, h4, h5, h6 {
margin: 0;
}
#navigation {
float: left;
width: 150px;
}
#content {
float: left;
width: 430px;
}
#footer {
clear: both;
}
Page Numbers :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17