Professional Documents
Culture Documents
1st Day
1st Day
Advantages of CSS
Selector: A selector is an HTML tag at which style will be applied. This could be any
tag like <h1> or <table> etc.
Property: A property is a type of attribute of HTML tag. Put simply, all the HTML
attributes are converted into CSS properties. They could be color or border etc.
Value: Values are assigned to properties. For example color property can have value
either red or #F1F1F1 etc
Internal CSSrules into an HTML document using the <style> element. This tag is
placed inside <head>...</head> tags.
<head>
<style type="text/css">
Style Rules
............
</style>
</head>
Inline style
An inline style can be used if a unique style is to be applied to one single occurrence
of an element.
<html>
<head>
</head>
<body style="background-color:gray">
</body>
</html>
CSS uses color values to specify a color. Typically, these are used to set a color either
for the foreground of an element(i.e., its text) or else for the background of the
element. They can also be used to affect the color of borders and other decorative
effects.
RGB :%rgb(rrr%,ggg%,bbb%)
RGB Absolute:rgb(rrr,ggg,bbb)
CSS Id and Class
id Selector
The id selector uses the id attribute of the HTML element, and is defined with a "#".
#para1
{
text-align:center;
color:red;
}
<html>
<head>
<style type="text/css">
p{color:blue;font-size:50px};
#para{color:green; }
</style>
</head>
<body>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
</body>
</html>
The class selector is used to specify a style for a group of elements. The class selector
uses the HTML class attribute, and is defined with a "."
.center {text-align:center;}
<html>
<head>
<style type="text/css">
p{color:blue;font-size:50px}
.para{color:green; }
</style>
</head>
<body>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
</body>
</html>
Background Property:
<html>
<head>
<style type="text/css">
body{background-color:Green; }
</style>
</head>
<body>
</body>
</html>
<head>
<style type="text/css">
Body{background-image: url(pic.jpg);}
</style>
</head>
<body>
</body>
</html>
<html>
<head>
<style type="text/css">
Body{background-image: url(pic.jpg);background-repeat:repeat}
</style>
</head>
<body>
</body>
</html>
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
</body>
</html>
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
</html>
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
</body>
</html>
how to set the background image position 100 pixels away from the left side.
<html>
<head>
<style type="text/css">
</style>
</head>
<body>
</body>
</html>
<html>
<head>
<style type="text/css">
</head>
<body>
</body>
</html>
<html>
<head>
<style type="text/css">
</head>
<body>
<p>Hello! This is my frist CSS</p>
</body>
</html>
<html>
<head>
<style type="text/css">
</head>
<body>
</body>
</html>
Fonts CSS
<html>
<style type=”text/css”>
P {font-family:georgia,garamond,serif
}
</style>
<head>
</head>
<body>
<p>This is a paragraph</p>
</body>
</html>
<html>
<style type=”text/css”>
P { font-style:italic; }
</style>
<head>
</head>
<body>
<p>This is a paragraph</p>
</body>
</html>
<html>
<style type=”text/css”>
P { font-variant:small-caps
;}
</style>
<head>
</head>
<body>
<p>This is a paragraph</p>
</body>
</html>
The font-weight property is used to increase or decrease how bold or light a font
appears.font-weight property provides the functionality to specify how bold a font is.
Possible values could be normal, bold, bolder, lighter, 100, 200, 300, 400, 500, 600,
700, 800, 900.
<html>
<style type=”text/css”>
P { font-weight:bold
;}
</style>
<head>
</head>
<body>
<p>This is a paragraph</p>
</body>
</html>
The font-size property is used to increase or decrease the size of a font.The font-size
property is used to control the size of fonts. Possible values could be xx-small, x-
small, small, medium, large, x-large, xx-large, smaller, larger, size in pixels or in %.
<html>
<style type=”text/css”>
P { font-size:50px;
;}
</style>
<head>
</head>
<body>
<p>This is a paragraph</p>
</body>
</html>
The font property is used as shorthand to specify a number of other font properties .
<html>
<style type=”text/css”>
P { font:50px bold
;}
</style>
<head>
</head>
<body>
<p>This is a paragraph</p>
</body>
</html>
Text CSS
<html>
<head>
<style type="text/css">
h1 {color:red;}
p {color: green;}
</style>
</head>
<body>
<h1>New Delhi</h1>
<p>New Delhi, Feb 7 (IANS) Actress Ayesha Takia is upset after a ground staff
member of Kingfisher Airlines misbehaved with her younger sister Nisha at the
airport.
"Been getting retweets about Ayesha Takia and KFA. not too sure who she is, an actor
of some sorts?? But it seems something has upset her!!" he posted. </p>
</body>
</html>
The direction property is used to set the text direction.Possible values are ltr or rtl.
<html>
<head>
<style type="text/css">
h1 {direction:rtl;}
p {color: green;}
</style>
</head>
<body>
<h1>New Delhi</h1>
<p>New Delhi, Feb 7 (IANS) Actress Ayesha Takia is upset after a ground staff
member of Kingfisher Airlines misbehaved with her younger sister Nisha at the
airport.
"Been getting retweets about Ayesha Takia and KFA. not too sure who she is, an actor
of some sorts?? But it seems something has upset her!!" he posted. </p>
</body>
</html>
The letter-spacing property is used to add or subtract space between the letters that
make up a word.
<html>
<head>
<style type="text/css">
h1 {letter-spacing:2px;}
h2 {letter-spacing:-3px;}
</style>
</head>
<body>
<h1>Welcome to Cncwerbworld</h1>
</body>
</html>
The word-spacing property is used to add or subtract space between the words of a
sentence.
<html>
<head>
<style type="text/css">
p {word-spacing:40px;}
</style>
</head>
<body>
<p>
SRK keeps updating the comments/opinions of his two kids. Recently he tweeted that
his daughter's remarks made him feel on top of the world. 'My lil girl said she is
proud of me... uff feel 6 ft 2 inches tall... loved and blessed to have her in my life. My
beautiful girl,' (sic) Shah Rukh wrote. Though the 11-year-old is quite proud of her
dad, that doesn't mean she approves his bad habits as well..
</p>
</body>
</html>
<html>
<head>
<style type="text/css">
p {text-indent:80px;}
</style>
</head>
<body>
<p>Daughter just reprimanded me... how can u be the HT survey youth role model if
you smoke. So to all the youths out there... please don't smoke!! (sic)" tweeted Shah
Rukh. "Big reprimand for smoking from my strict little atom bomb of a daughter!!!"
he added. 46-year-old King Khan is said to be a chain-smoker but has admitted
smoking is the "worst habit". '</p>
</body>
</html>
<html>
<head>
<style type=”text/css”>
H1{text-align:center}
H1{text-align:right}
</style>
</head>
<body>
<p>Feb, 2012</p>
<p>His fans look up to him as an idol, but superstar Shah Rukh Khan's daughter
Suhana believes her father isn't the perfect youth icon as he smokes a lot.</p>
</body>
</html>
<head>
<style type="text/css">
a:link {text-decoration:none;}
a:visited {text-decoration:none;}
a:hover {text-decoration:underline;}
a:active {text-decoration:underline;}
</style>
</head>
<body>
<p><b><a href="http://www.auxir.com">Auxir</a></b></p>
<p>SRK keeps updating the comments/opinions of his two kids. Recently he tweeted
that his daughter's remarks made him feel on top of the world. 'My lil girl said she is
proud of me... uff feel 6 ft 2 inches tall... loved and blessed to have her in my life. My
beautiful girl,' (sic) Shah Rukh wrote. Though the 11-year-old is quite proud of her
dad, that doesn't mean she approves his bad habits as well.</p>
</body>
</html>
<html>
<head>
<style type="text/css">
p{text-transform:uppercase;}
</style>
</head>
<body>
</body>
</html>
The white-space property is used to control the flow and formatting of text.Possible
values are normal, pre, nowrap.
<html>
<head>
<style type="text/css">
P{white-space:pre;}
</style>
</head>
<body>
<p><b><a href="http://www.auxir.com">Auxir</a></b></p>
<p>SRK keeps updating the comments/opinions of his two kids. Recently he tweeted
that his daughter's remarks made him feel on top of the world. 'My lil girl said she is
proud of me... uff feel 6 ft 2 inches tall... loved and blessed to have her in my life. My
beautiful girl,' (sic) Shah Rukh wrote. Though the 11-year-old is quite proud of her
dad, that doesn't mean she approves his bad habits as well.</p>
</body>
</html>