Chapter-3 CSS
Chapter-3 CSS
Web Workshop:
Part 2:CSS
Objectives:
- “What is CSS?”
- Structure of CSS
- How to use CSS in your webpage
What
Whatis isCSS?
CSS?(1)
CSS stands for “Cascading Style Sheets”
Value
Attribute Name
CSS Color Specifier
• Predefined names:
white black red …
• 8-bit hexadecimal intensities for red, green, blue:
#ff0000
R G B
• 0-255 decimal intensities:
rgb(255,255,0)
R intensities:
• Percentage G B
rgb(80%,80%,100%)
How to write style rules
• Style has two parts: (1) selector and
(2) declaration.
• Selector: the HTML element you want to add style to.
}
• Example: Illustration of grouping id-selector
• <html>
<head>
<style>
#greet {
color: purple;
font-family : arial;
}
</style>
</head>
<body>
<div id= "greet"> WELCOME!!!</div>
<p> Welcome Students!</p>
<div id="greet"> <p> We will learn CSS</p></div>
</body>
Example
– <html>
<head>
<style>
h1, p {color : red;}
</style>
</head>
<body>
<h1> Welcome </h1>
<p> welcome Students </p>
</body>
3. Universal selector
– The universal selector, written "*", matches the
name of any element type.
– e.g.
* {border: 2px;}
4. Descendant Selector
– Sometimes, you want selectors to match an element that is the
descendant of another element in the document tree.
– (e.g., "Match those EM elements that are contained by an H1
element").
– Descendant selectors express such a relationship in a pattern.
Essentially means:
h1 {color: red;}
p {color: yellow;}
This is the text in this paragraph.
How
Howtotowrite
writestyle
stylerules
rules(4)
Selector {property: value;}
h1 {color: yellow;
background-color: white;}
Means:
Speaking of my heading1, I want the text
color to be yellow and the background color
to be red.
How to write style rules
a { color: red;
background color:yellow;
}
This is my link
WhereThree types
do I put myofstyle
stylerules?
This is a style
sheet (style type)
written (text) in
CSS language
<style type=“text/css”>
…
</style>
Internal: Brackets & Declaration
1. rel
•It is used to specify a relationship of CSS with HTML
document.
•Its default relationship value is “style sheet”.
2. type
•Type attribute is not used in META tag.
3. href
•It points to the external style sheet file's URL.
4. title
•It is optional.
5. media
•It specifies the medium on which style sheet
should be applied.
•Its default value is screen.
1. normal
2. small-caps
•In this all lower case letters are converted to upper case letters.
•bold
•bolder
•lighter
•100-900
Conti…
5. font-size
•This property sets the size of the text.
</html>
Example: Font properties
<html> .fp5 {
<head> <title>External style sheet</title> font-weight: lighter;
<style type="text/css"> }
.fp { .fp6 {
font-family: verdana; font-weight: bold;
} }
.fp1 { .fp7 {
font-style:italic; font-weight: 800;
} }
.fp2 { .fp8 {
font-variant: normal; font-size: normal;
} }
.fp3 { .fp9 {
font-variant: small-caps; font-size: xx-small;
} }
.fp4 { .fp10 {
font-weight: normal; font-size: 30px; }
} </style>
</head>
CSS supports the following border properties
1. Border-style 2. Border-width
values for border-style properties : specifies the width of the four borders.
solid The values for border-width property
Double are:
Groove thick
dotted thin
dashed medium
</body>
</html>
CSS supports the following border properties
3. Border-color 4. Border-direction
Border colors are set by: The border direction values are: top/
Specifying a color name, like bottom/ right/ left
“orange”. Example:
Specifying hex value, like border-bottom-style: solid;
“#ff0000”. border-bottom-color: red;
Specifying RGB value, like border-bottom-width: 5 px;
“rgb(255,0,0)”. •border-All in one
It is used to create a uniform border.
•border: 10px outset green;
CSS Link Properties