CSS Stands For Cascading Style Sheets. It Is A Style Sheet Language That Acts As The Presentation Layer For Markup Languages Such As HTML and XHTML
CSS Stands For Cascading Style Sheets. It Is A Style Sheet Language That Acts As The Presentation Layer For Markup Languages Such As HTML and XHTML
selector selectorname
{ property:value;
...
}
color : yellow;
h1 h2 h3
{
property:value;
...
}
DESCENDANT SELECTORS
{
property:value;
...
}
HTML document:
· Inline
· Internal
· External Link
INLINE STYLESHEET
div { background-color:#FF0000; }
</style>
</head><body>
Class is specified by including a period (.) before the selector name. The syntax
.[Class Name] {
property:value;
...
For example,
.navbar {
color:#0000FF;
.applylarge {
font-size:20px;
.applyred {
color:#FF0000;
would render,
ID is specified by including a sign (#) before the selector name. The syntax
#[ID Name]
{property:value; }
For example,
#footer {
color:#FF00FF;
<style type="text/css">
#greenidstyle {color:green}
.redclassstyle {color:red}
</style>
<!--HTML part:-->
<body>
combined</p>
</body>
DIV
Div divides the content into individual sections. Each section can then have its
.large {
color: #00FF00;
font-family:arial;
font-size: 4pt;
<div class="large">
</div>
gets displayed as
CSS Declaration:-
p {border-width:9px; border-style:solid;}
p {border-width:medium; border-style:dashed;}
BORDER COLOR
The border-color property specifies the color of the
border.
Examples below:
CSS Declaration:-
p {border-color:#0000FF; border-style:solid;}
p {border-color:red; border-style:dotted;}
BORDER-LEFT,BORDER-RIGHT,BORDER-TOP,BORDER-
BOOTOM
Directions (top, left, bottom, right) can be combined with style, width,
style specifies the style of the top border. Some examples below:
CSS Declaration:-
p {border-top-style:solid; border-bottom-style:dotted;}
p {border-top-style:solid; border-top-width:medium;}
p {border-left-style:solid; border-bottom-style:dashed;
border-bottom-color:#00FF00;}
BORDER
background.
fixed on the screen. Possible values are "fixed" (background stays in the
same place when scrolling) and "scroll" (background moves with the rest of
background-image: url("yp.jpg");
background-repeat: no-repeat;
background-image: url("yp.jpg");
background-repeat: no-repeat;
}
BACKGROUND-COLOR
CSS Declaration:
Output
p {background-color: 00FF00;}
p{background-color: red;}
BACKGROUND-COLOR
In the CSS Background-color property page, we can specify
a single color for the background. What if we want to use an
image for our background? That's what the background-
image property is for.
Example:-
CSS Declaration:-
p {background-image:url(yp.jpg);}
Two percentage values: The first value indicates the horizontal percentage,
Two position values: The first value is the absolute horizontal position, the
Examples :-
background-position: center; }
p{
background-image:url(yp.jpg);
background-repeat: repeat-x; }
Background repeats horizontally.
p{
background-image:url(yp.jpg);
background-repeat: repeat-y; }
Background repeats vertically.
p{
background-image:url(yp.jpg);
background-repeat: repeat; }
Background repeats in both directions.
FONT
The default style for a link is blue font with an underline. This is, however,
not always ideal. There are times when we want links to have a different
a:link: Specifies how the link looks if the page it links to has not yet been
visited.
a:visited: Specifies how the link looks if the page it links to has already been
visited.
a:hover: Specifies how the link looks like when the user mouses over the
link.
a:active: Specifies how the link looks like when the user clicks on it.
The following declaration:-
3) When you mouse over the link, font size becomes 20, font color
4) When you click on the link, font color becomes pink, and the
underline remains.
LIST
tr {
border-bottom:1px solid #000; }
the HTML code below:-
<table>
<tr><td>Year</td><td>Income</td></tr>
<tr><td>2006</td><td>35.2M</td></tr>
<tr><td>2007</td><td>40.1M</td></tr> </table>
would render the following:
Year Income
2006 35.2M
2007 40.1M
Notice that the underline between the Year column and the Income column are
continuous. The is the effect of border-collapse:collapse.
POSITION
values include:
static (default): indicates that the element will be placed at the default
location. Please note that if static is specified, values for the top, bottom,
position of the element moves along with the rest of the content when the
page is scrolled.
relative: specifies how the element will be positions relative to how it would
position of the element remains fixed even when the page is scrolled.
additional properties are needed to complement the position
property. They are as follows:
· top
· right
· left
· bottom
· overflow
· z-index
SESSION
The absolute value of the position property means that the element
will be displayed in the same location within the browser, with the
location being determined by top, bottom, left, or right properties. The
element will move with the rest of the content when scrolling. As an
example, you will see a red ball 550 pixels from the top of the browser
and 400 pixels from the left of the browser. The code for this is:
p{
position:absolute;
top:50px;
left:600px;
}
The HTML code,
<div>
<p><img src="red-ball.jpg">
</div>
renders the image you see that is 50px from the top of the browser
and 600px from the left of the browser. Please notice that as you
scroll up and down and page, the red ball moves along with the rest
of the page. This is different from when we specify {position:fixed;},
when the red ball stays in the same place as the rest of the page
moves.
RELATIVE
The relative value of the position property specifies how the element will be positions relative to
how it would have been positioned by default. It is used in combination with a direction (top,
bottom, left, and right).
Example
CSS Code
div {
background-color:#FF00FF;
width:250px;
height:60px; }
p{}
The HTML code,
<div>
<p>Example to show relative position. </div>
renders
Example:-
div {
background-color:#FF00FF;
width:250px;
height:60px; }
p{
position:relative;
top:15px; }
<div>
<p>Example to show relative position. </div>
Example to show relative position.
In the above example, applying the {position:relative; top:15px;} style added 15px of space on top
of the text. In other words, this style shifted the text down by 15px relative to the default position.
FIXED-PROPERTY
The fixed value of the position property means that the element will
always be displayed in the same location within the browser, with the
location being determined by top, bottom, left, or right properties. As
an example, you will see a red ball 50 pixels from the top of the
browser. As you scroll down the page, that red ball stays in the same
place. The code for this is:
p{
position:fixed;
top:50px;
left:650px; }
The HTML code,
<div>
<p><img src="red-ball.jpg"> </div>
renders the image you see that is 50px from the top of the browser
and 650px from the left of the browser. Please notice that as you
scroll up and down and page, the red ball stays in the same place.
STATIC PROPERTY
{cursor: not-allowed; }
Mouse cursor is set to not-allowed
{ cursor: no-drop; }
Mouse cursor is set to no-drop
{ cursor: no-vertical-text; }
Mouse cursor is set to no-vertical-text
{ cursor: all-scroll; } Mouse cursor is set to nw-resize
Mouse cursor is set to all-scroll { cursor: w-resize; }
{ cursor: col-resize; } Mouse cursor is set to w-resize
Mouse cursor is set to col-resize { cursor: sw-resize; }
{ cursor: row-resize; } Mouse cursor is set to sw-resize
Mouse cursor is set to row- { cursor: s-resize; }
resize Mouse cursor is set to s-resize
{ cursor: e-resize; } { cursor: se-resize; }
Mouse cursor is set to e-resize Mouse cursor is set to se-resize
{ cursor: ne-resize; } We can also specify a custom
Mouse cursor is set to ne-resize image for the mouse cursor. The
{ cursor: n-resize; } syntax for doing this is:
Mouse cursor is set to n-resize { cursor: url(image_url); }
{ cursor: nw-resize; }
TEXT-WRAP PROPERTY
Text wrap can be achieved in CSS using the white-space
property. Common values of this property are as follows: