TechnoCSS
TechnoCSS
WEST BENGAL
CSS
(Cascading Style Sheet)
-Contd.
1
TECHNO INDIA UNIVERSITY
WEST BENGAL
The border-style property can have from one to four values (for the top
border, right border, bottom border, and the left border). 2
TECHNO INDIA UNIVERSITY
WEST BENGAL
Example:
<!DOCTYPE html> p.five {
<html> border-style: double;
<head> border-width: 15px;
<style> }
p.six {
p.one {
border-style: double;
border-style: solid; border-width: thick;
border-width: 5px; }
} </style>
p.two { </head>
<body>
border-style: solid;
<h2>The border-width Property</h2>
border-width: medium; <p>This property specifies the width of the four borders:</p>
} <p class="one">Some text.</p>
p.three { <p class="two">Some text.</p>
border-style: dotted; <p class="three">Some text.</p>
<p class="four">Some text.</p>
border-width: 2px;
<p class="five">Some text.</p>
} <p class="six">Some text.</p>
p.four {
border-style: dotted; <p><b>Note:</b> The "border-width" property does not work if it is used alone.
border-width: thick; Always specify the "border-style" property to set the borders first.</p>
</body> 3
}
</html>
TECHNO INDIA UNIVERSITY
WEST BENGAL
Specific Side Widths: The border-width property can have from one to four
values (for the top border, right border, bottom border, and the left
border):
p.one {
border-style: solid;
border-width: 5px 20px; /* 5px top and bottom, 20px on the sides */
}
p.two {
border-style: solid;
border-width: 20px 5px; /* 20px top and bottom, 5px on the sides */
}
p.three {
border-style: solid;
border-width: 25px 10px 4px 35px; /* 25px top, 10px right, 4px bottom and 35px
left */
}
5
TECHNO INDIA UNIVERSITY
WEST BENGAL
p.one {
border-style: solid;
border-color: red green blue yellow; /* red top, green right, blue bottom and yellow left
*/
} 6
TECHNO INDIA UNIVERSITY
WEST BENGAL
8
TECHNO INDIA UNIVERSITY
WEST BENGAL
CSS Margins
• The CSS margin properties are used to create space around elements, outside
of any defined borders.
• With CSS, you have full control over the margins. There are properties for
setting the margin for each side of an element (top, right, bottom, and left).
Margin - Individual Sides
CSS has properties for specifying the margin for each side of an element:
– margin-top
– margin-right
– margin-bottom
– margin-left
If the margin property has one value: If the margin property has two values:
p{ p{
margin: 25px; margin: 25px 50px;
} }
❖all four margins are 25px ❖ top and bottom margins are
25px
❖ right and left margins are 50px
Margin Collapse
• Top and bottom margins of elements are sometimes collapsed into a
single margin that is equal to the largest of the two margins.
• This does not happen on left and right margins! Only top and bottom
margins!
<!DOCTYPE html>
<html>
<head>
<style>
h1 {
margin: 0 0 50px 0;
}
h2 {
margin: 20px 0 0 0;
}
</style>
</head>
<body>
<p>In this example the h1 element has a bottom margin of 50px and the h2 element has a top
margin of 20px. So, the vertical margin between h1 and h2 should have been 70px (50px +
20px). However, due to margin collapse, the actual margin ends up being 50px.</p>
<h1>Heading 1</h1>
<h2>Heading 2</h2>
</body> 15
</html>
TECHNO INDIA UNIVERSITY
WEST BENGAL
CSS Padding
• The CSS padding properties are used to generate space around an element's content,
inside of any defined borders.
• With CSS, you have full control over the padding. There are properties for setting the
padding for each side of an element (top, right, bottom, and left).
<!DOCTYPE html> <body>
<html>
<head> <h2>Using individual
<style> padding properties</h2>
<div>This div element has a
div { top padding of 50px, a right
border: 1px solid black; padding of 30px, a bottom
background-color: lightblue; padding of 50px, and a left
padding-top: 50px; padding of 80px.</div>
padding-right: 30px; </body>
padding-bottom: 50px; </html>
padding-left: 80px;
}
</style>
16
</head>
TECHNO INDIA UNIVERSITY
WEST BENGAL
If the padding property has two If the padding property has one
values: value:
padding: 25px 50px; padding: 25px;
• top and bottom paddings are all four paddings are 25px
25px
• right and left paddings are 50px
17
TECHNO INDIA UNIVERSITY
WEST BENGAL
<!DOCTYPE html>
<html>
<head>
<style>
div {
background-color: lightgrey;
width: 300px;
border: 15px solid green;
padding: 50px;
margin: 20px;
}
</style>
</head>
<body>
<h2>Demonstrating the Box Model</h2>
<p>The CSS box model is essentially a box that wraps around every HTML element. It consists of: borders,
padding, margins, and the actual content.</p>
<div>Check the example.</div>
</body>
</html>
19
TECHNO INDIA UNIVERSITY
WEST BENGAL
CSS Outline
• An outline is a line drawn outside the element's border.
• An outline is a line that is drawn around elements, OUTSIDE the borders, to
make the element "stand out".
CSS has the following outline properties:
– outline-style
– outline-color
– outline-width CSS Outline Style
The outline-style property specifies the style of the outline, and can have one
– outline-offset of the following values:
dotted - Defines a dotted outline
– outline
dashed - Defines a dashed outline
solid - Defines a solid outline
double - Defines a double outline
groove - Defines a 3D grooved outline
ridge - Defines a 3D ridged outline
inset - Defines a 3D inset outline
outset - Defines a 3D outset outline
none - Defines no outline 22
hidden - Defines a hidden outline
TECHNO INDIA UNIVERSITY
WEST BENGAL
23
TECHNO INDIA UNIVERSITY
WEST BENGAL
26
TECHNO INDIA UNIVERSITY
WEST BENGAL
Thank You
27