SlideShare a Scribd company logo
1
Web Engineering
Lecture 06
Basic CSS Properties
University of Lahore
Nosheen Qamar
CSS background Properties
• You can set background of various HTML
elements:
 The background-color property is used to set the
background color of an element.
 The background-image property is used to set the
background image of an element.
 The background-repeat property is used to
control the repetition of an image in the
background.
 The background-position property is used to
control the position of an image in the background.
 The background-attachment property is used to
control the scrolling of an image in the background.
3
background-color
• <p style=“background-color: yellow;” >
This text has a yellow background. </p>
• Output:
• Possible values:
any color in a valid format.
4
background-image
• <table style=“background-image:url(images/css.gif);” >
<tr><td>
this table has background image which repeats
multiple times.
</td></tr>
</table>
• Output:
• Possible values:
any image with valid format
5
background-repeat
• <table style=“background-image: url(images/cat.gif);
background-repeat: no-repeat; ” >
<tr><td>
by default background-repeat property have repeat
value.
</td></tr>
</table>
• Output:
• Possible values:
repeat, repeat-y, repeat-x, no-repeat
6
background-size
• <table style=“background-image: url(images/cat.gif);
background-repeat: no-repeat;
background-size: 200px 200px; ” >
<tr><td>
background-size property is used to expand the
background image.
</td></tr>
</table>
• Output:
• Possible values:
repeat, repeat-y, repeat-x, no-repeat
7
background-position
• <table style=“background-image: url(images/css.gif);
background-position: 100px 200px; ” >
<tr><td>
this table has background image positioned 100 pixels
away from the left and 200 pixels from the top.
</td></tr>
</table>
• Output:
• Possible values:
X% Y%, top left, Xpx Ypx
left
top
center
top
left
bottom
center
bottom
right
bottom
8
background-attachment
• <p style=“background-image:url(images/css.gif);
background-attachment: fixed; ” >
This paragraph has fixed background image.
</p>
• Output:
• Possible values:
fixed, scroll
CSS Borders
• You can set following border properties of
an element:
 The border-color property is used to set the
color of the border.
 The border-style property is used to set the
style of border.
 The border-width property is used to set .
 The border property is used to set the width,
style and color of the border in one declaration.
border-style
• <p style=“border-style: none”>
This is a border with none width.</p>
<p style=“border-style: solid”>
This is a solid border.</p>
<p style=“border-style: dashed”>
This is a dashed border.</p>
• Output:
• Possible values:
none, solid, dashed, double, groove, ridge, inset, outset
border-color
• <style>
p.example1 {
border-style: solid;
border-bottom-color: #009900;
border-top-color: #FF0000;
border-left-color: #330000;
border-right-color: #0000CC;
}
</style>
<p class=“example1”>
This example is showing all borders in different colors.
</p>
• Output:
• Possible values:
any color with valid format
border-color
• <style>
p.example1 {
border-style: solid;
border-color: #FF0000;
}
</style>
<p class=“example1”>
This example is showing all borders in same color.
</p>
• Output:
• Possible values:
any color with valid format
border-width
• <p style=“border-width: 4px; border-style:
solid;”>
This is a solid border whose width is
4px.</p>
• Output:
• Possible values:
length in px, pt or cm or it should be thin,
medium or thick.
• You can individually change the width of
the bottom, top, left and right borders of an
element. Using the following properties:
 border-bottom-width changes the width of
bottom border.
 border-top-width changes the width of top
border.
 border-left-width changes the width of left
border.
 border-right-width changes the width of right
border.
14
border-width
• <style>
p.example1 {
border-style: solid;
border-bottom-width: 6pt;
border-top-width: 6pt;
border-left-width: 4pt;
border-right-width: 4pt;
}
</style>
<p class=“example1”>
This example is showing all borders in different widths.
</p>
• Output:
• Possible values:
any color with valid format
This example is showing all borders in different widths.
border
• <p style=“border: 4px solid red;”>
This example is showing shorthand
property for border.</p>
• Output:
CSS Margins
• You can set following margin properties of
an element:
 The margin-bottom property specify the
bottom margin of an element.
 The margin-top property specify the top
margin of an element.
 The margin-left property specify the left margin
of an element.
 The margin-right property specify the right
margin of an element.
 The margin shorthand property for setting
margin properties in one declaration.
margin
• <div style=“margin: 20px;”>
This is a paragraph with a specified margin
from all sides.</div>
• Output:
• Possible values:
auto, length in px, %.
margin-top
• <div style=“margin-top: 10px;”>
This is a paragraph with a specified top
margin.</div>
• Output:
• Possible values:
auto, length in px, %.
margin-bottom
• <div style=“margin-bottom: 10px;”>
This is a paragraph with a specified bottom
margin.</div>
• Output:
• Possible values:
auto, length in px, %.
margin-left
• <div style=“margin-left: 10%;”>
This is a paragraph with a specified left
margin.</div>
• Output:
• Possible values:
auto, length in px, %.
margin-right
• <div style=“margin-right: 10%;”>
This is a paragraph with a specified right
margin.</div>
• Output:
• Possible values:
auto, length in px, %.
23
Margin property
• <style>
p {margin: 15px; }
all four margins will be 15px
p {margin: 10px 5px; }
top and bottom margin will be 10px, left and right
will be 2% of the total width of doc.
p {margin: 10px 8px 20px 15px; }
top margin will be 10px, right margin will be 2%,
bottom
margin will be -10px, left margin will be set by the
browser
</style>
CSS Padding
• Padding property allows you to specify how
much space should appear between the
content of an element and its border :
 The padding-bottom property specify the bottom
padding of an element.
 The padding-top property specify the top padding
of an element.
 The padding-left property specify the left padding
of an element.
 The padding-right property specify the right
padding of an element.
 The padding shorthand property serves as the
preceding properties.
padding-bottom
• <p style=“padding-bottom: 15px; border-
width: 1px solid black;”>
This is a paragraph with a specified bottom
padding.</p>
• Output:
This is a paragraph with a specified bottom
padding.
• Possible values:
length in px, %.
padding-top
• <p style=“padding-top: 15px; border-width:
1px solid black;”>
This is a paragraph with a specified top
padding.</p>
• Output:
This is a paragraph with a specified top
padding.
• Possible values:
length in px, %.
padding-left
• <p style=“padding-left: 15px; border-width: 1px
solid black;”>
This is a paragraph with a specified left
padding.</p>
• Output:
This is a paragraph with a specified top
padding.
• Possible values:
length in px, %.
padding-right
• <p style=“padding-right: 15px; border-width:
1px solid black;”>
This is a paragraph with a specified right
padding.</p>
• Output:
This is a paragraph with a specified top
padding.
• Possible values:
length in px, %.
padding
• <p style=“padding: 15px; border-width: 1px
solid black;”>
This is a paragraph with a specified right
padding.</p>
• Output:
This is a paragraph with a specified
top padding.
• Possible values:
length in px, %.
Padding and Margin Properties
• Values for both the padding and the margin
properties can be expressed using:
• em (em values)
• px (pixels)
• mm (millimeters)
• cm (centimeters)
• in (inches)
• % (percentage of the container element)

More Related Content

PPTX
Web Engineering - Introduction to CSS
PDF
Web Design Course: CSS lecture 3
PDF
Web Design Course: CSS lecture 2
PPTX
CSS tutorial chapter 3
PPTX
CSS tutorial chapter 2
PPTX
CSS Basics part One
PDF
Web Design Course: CSS lecture 4
PDF
Web Design Course: CSS lecture 1
Web Engineering - Introduction to CSS
Web Design Course: CSS lecture 3
Web Design Course: CSS lecture 2
CSS tutorial chapter 3
CSS tutorial chapter 2
CSS Basics part One
Web Design Course: CSS lecture 4
Web Design Course: CSS lecture 1

What's hot (20)

PPTX
Kick start @ css
PPTX
Cascading Style Sheets - CSS
PPTX
Cascading style sheets - CSS
PDF
Web Design Course: CSS lecture 5
PPTX
Css Complete Notes
PDF
Introduction to CSS
PPT
Cascading Style Sheets(CSS)
PPTX
Css3 Complete Reference
PPT
Cascading Style Sheets By Mukesh
PPT
How Cascading Style Sheets (CSS) Works
PDF
Basic-CSS-tutorial
PPT
PPT
CSS for Beginners
PDF
CSS Selectors
PPTX
Understanding CSS for web development by software outsourcing company india
PPT
cascading style sheet ppt
PPT
Make Css easy : easy tips for css
PDF
Pemrograman Web 3 - CSS Basic Part 2
PDF
Pemrograman Web 2 - CSS
Kick start @ css
Cascading Style Sheets - CSS
Cascading style sheets - CSS
Web Design Course: CSS lecture 5
Css Complete Notes
Introduction to CSS
Cascading Style Sheets(CSS)
Css3 Complete Reference
Cascading Style Sheets By Mukesh
How Cascading Style Sheets (CSS) Works
Basic-CSS-tutorial
CSS for Beginners
CSS Selectors
Understanding CSS for web development by software outsourcing company india
cascading style sheet ppt
Make Css easy : easy tips for css
Pemrograman Web 3 - CSS Basic Part 2
Pemrograman Web 2 - CSS
Ad

Viewers also liked (20)

PPTX
Need for Web Engineering
PPTX
Web Engineering - Web Application Testing
PPTX
Web engineering - Measuring Effort Prediction Power and Accuracy
ODP
PPTX
Web engineering - An overview about HTML
PDF
PROGRESS - CSS BASIC
PPTX
Web engineering - HTML Form
PPT
Cascading Style Sheet
PPTX
Week 12 CSS - Review from last week
PPTX
Cascading Style Sheet (CSS)
PPTX
Angular js for beginners
PDF
[Basic HTML/CSS] 4. html - form tags
PDF
[Basic HTML/CSS] 3. html - table tags
PPTX
HTML Forms
PPTX
Css ppt
PPTX
Cascading style sheet
PPT
Tables and Forms in HTML
PPT
Html & Css presentation
PPSX
CSS-Cascading Style Sheets - Introduction
PPTX
CSS3 notes
Need for Web Engineering
Web Engineering - Web Application Testing
Web engineering - Measuring Effort Prediction Power and Accuracy
Web engineering - An overview about HTML
PROGRESS - CSS BASIC
Web engineering - HTML Form
Cascading Style Sheet
Week 12 CSS - Review from last week
Cascading Style Sheet (CSS)
Angular js for beginners
[Basic HTML/CSS] 4. html - form tags
[Basic HTML/CSS] 3. html - table tags
HTML Forms
Css ppt
Cascading style sheet
Tables and Forms in HTML
Html & Css presentation
CSS-Cascading Style Sheets - Introduction
CSS3 notes
Ad

Similar to Web Engineering - Basic CSS Properties (20)

PPT
Lecture5.ppt C style sheet notes for B.CA and BIT
PPTX
Css presentation lecture 4
PPTX
Css margins
PDF
PPTX
Cascading style sheet part 2
PPTX
Css padding
PDF
Web Layout
PPTX
CSS Cascade Style Sheet
PPTX
Unit - 3 CSS(Cascading Style Sheet).pptx
PPTX
Web Development - Lecture 6
PDF
Lab#7 CSS Box Model
PDF
basics of css
DOC
Simple Blue Blog Template XML 的副本
PPTX
Css & css3
PPTX
Web - CSS 1.pptx
PDF
IT2255 Web Essentials - Unit II Web Designing
PPTX
Pres
PPTX
Css outlines
PPTX
Lecture5.ppt C style sheet notes for B.CA and BIT
Css presentation lecture 4
Css margins
Cascading style sheet part 2
Css padding
Web Layout
CSS Cascade Style Sheet
Unit - 3 CSS(Cascading Style Sheet).pptx
Web Development - Lecture 6
Lab#7 CSS Box Model
basics of css
Simple Blue Blog Template XML 的副本
Css & css3
Web - CSS 1.pptx
IT2255 Web Essentials - Unit II Web Designing
Pres
Css outlines

Recently uploaded (20)

PDF
Business Ethics Teaching Materials for college
PPTX
Cell Structure & Organelles in detailed.
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Basic Mud Logging Guide for educational purpose
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
PPTX
Microbial diseases, their pathogenesis and prophylaxis
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
TR - Agricultural Crops Production NC III.pdf
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
master seminar digital applications in india
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
Open folder Downloads.pdf yes yes ges yes
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Business Ethics Teaching Materials for college
Cell Structure & Organelles in detailed.
2.FourierTransform-ShortQuestionswithAnswers.pdf
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Basic Mud Logging Guide for educational purpose
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Microbial diseases, their pathogenesis and prophylaxis
Week 4 Term 3 Study Techniques revisited.pptx
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
Microbial disease of the cardiovascular and lymphatic systems
TR - Agricultural Crops Production NC III.pdf
PPH.pptx obstetrics and gynecology in nursing
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
master seminar digital applications in india
Abdominal Access Techniques with Prof. Dr. R K Mishra
Open folder Downloads.pdf yes yes ges yes
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student

Web Engineering - Basic CSS Properties

  • 1. 1 Web Engineering Lecture 06 Basic CSS Properties University of Lahore Nosheen Qamar
  • 2. CSS background Properties • You can set background of various HTML elements:  The background-color property is used to set the background color of an element.  The background-image property is used to set the background image of an element.  The background-repeat property is used to control the repetition of an image in the background.  The background-position property is used to control the position of an image in the background.  The background-attachment property is used to control the scrolling of an image in the background.
  • 3. 3 background-color • <p style=“background-color: yellow;” > This text has a yellow background. </p> • Output: • Possible values: any color in a valid format.
  • 4. 4 background-image • <table style=“background-image:url(images/css.gif);” > <tr><td> this table has background image which repeats multiple times. </td></tr> </table> • Output: • Possible values: any image with valid format
  • 5. 5 background-repeat • <table style=“background-image: url(images/cat.gif); background-repeat: no-repeat; ” > <tr><td> by default background-repeat property have repeat value. </td></tr> </table> • Output: • Possible values: repeat, repeat-y, repeat-x, no-repeat
  • 6. 6 background-size • <table style=“background-image: url(images/cat.gif); background-repeat: no-repeat; background-size: 200px 200px; ” > <tr><td> background-size property is used to expand the background image. </td></tr> </table> • Output: • Possible values: repeat, repeat-y, repeat-x, no-repeat
  • 7. 7 background-position • <table style=“background-image: url(images/css.gif); background-position: 100px 200px; ” > <tr><td> this table has background image positioned 100 pixels away from the left and 200 pixels from the top. </td></tr> </table> • Output: • Possible values: X% Y%, top left, Xpx Ypx left top center top left bottom center bottom right bottom
  • 8. 8 background-attachment • <p style=“background-image:url(images/css.gif); background-attachment: fixed; ” > This paragraph has fixed background image. </p> • Output: • Possible values: fixed, scroll
  • 9. CSS Borders • You can set following border properties of an element:  The border-color property is used to set the color of the border.  The border-style property is used to set the style of border.  The border-width property is used to set .  The border property is used to set the width, style and color of the border in one declaration.
  • 10. border-style • <p style=“border-style: none”> This is a border with none width.</p> <p style=“border-style: solid”> This is a solid border.</p> <p style=“border-style: dashed”> This is a dashed border.</p> • Output: • Possible values: none, solid, dashed, double, groove, ridge, inset, outset
  • 11. border-color • <style> p.example1 { border-style: solid; border-bottom-color: #009900; border-top-color: #FF0000; border-left-color: #330000; border-right-color: #0000CC; } </style> <p class=“example1”> This example is showing all borders in different colors. </p> • Output: • Possible values: any color with valid format
  • 12. border-color • <style> p.example1 { border-style: solid; border-color: #FF0000; } </style> <p class=“example1”> This example is showing all borders in same color. </p> • Output: • Possible values: any color with valid format
  • 13. border-width • <p style=“border-width: 4px; border-style: solid;”> This is a solid border whose width is 4px.</p> • Output: • Possible values: length in px, pt or cm or it should be thin, medium or thick.
  • 14. • You can individually change the width of the bottom, top, left and right borders of an element. Using the following properties:  border-bottom-width changes the width of bottom border.  border-top-width changes the width of top border.  border-left-width changes the width of left border.  border-right-width changes the width of right border. 14
  • 15. border-width • <style> p.example1 { border-style: solid; border-bottom-width: 6pt; border-top-width: 6pt; border-left-width: 4pt; border-right-width: 4pt; } </style> <p class=“example1”> This example is showing all borders in different widths. </p> • Output: • Possible values: any color with valid format This example is showing all borders in different widths.
  • 16. border • <p style=“border: 4px solid red;”> This example is showing shorthand property for border.</p> • Output:
  • 17. CSS Margins • You can set following margin properties of an element:  The margin-bottom property specify the bottom margin of an element.  The margin-top property specify the top margin of an element.  The margin-left property specify the left margin of an element.  The margin-right property specify the right margin of an element.  The margin shorthand property for setting margin properties in one declaration.
  • 18. margin • <div style=“margin: 20px;”> This is a paragraph with a specified margin from all sides.</div> • Output: • Possible values: auto, length in px, %.
  • 19. margin-top • <div style=“margin-top: 10px;”> This is a paragraph with a specified top margin.</div> • Output: • Possible values: auto, length in px, %.
  • 20. margin-bottom • <div style=“margin-bottom: 10px;”> This is a paragraph with a specified bottom margin.</div> • Output: • Possible values: auto, length in px, %.
  • 21. margin-left • <div style=“margin-left: 10%;”> This is a paragraph with a specified left margin.</div> • Output: • Possible values: auto, length in px, %.
  • 22. margin-right • <div style=“margin-right: 10%;”> This is a paragraph with a specified right margin.</div> • Output: • Possible values: auto, length in px, %.
  • 23. 23 Margin property • <style> p {margin: 15px; } all four margins will be 15px p {margin: 10px 5px; } top and bottom margin will be 10px, left and right will be 2% of the total width of doc. p {margin: 10px 8px 20px 15px; } top margin will be 10px, right margin will be 2%, bottom margin will be -10px, left margin will be set by the browser </style>
  • 24. CSS Padding • Padding property allows you to specify how much space should appear between the content of an element and its border :  The padding-bottom property specify the bottom padding of an element.  The padding-top property specify the top padding of an element.  The padding-left property specify the left padding of an element.  The padding-right property specify the right padding of an element.  The padding shorthand property serves as the preceding properties.
  • 25. padding-bottom • <p style=“padding-bottom: 15px; border- width: 1px solid black;”> This is a paragraph with a specified bottom padding.</p> • Output: This is a paragraph with a specified bottom padding. • Possible values: length in px, %.
  • 26. padding-top • <p style=“padding-top: 15px; border-width: 1px solid black;”> This is a paragraph with a specified top padding.</p> • Output: This is a paragraph with a specified top padding. • Possible values: length in px, %.
  • 27. padding-left • <p style=“padding-left: 15px; border-width: 1px solid black;”> This is a paragraph with a specified left padding.</p> • Output: This is a paragraph with a specified top padding. • Possible values: length in px, %.
  • 28. padding-right • <p style=“padding-right: 15px; border-width: 1px solid black;”> This is a paragraph with a specified right padding.</p> • Output: This is a paragraph with a specified top padding. • Possible values: length in px, %.
  • 29. padding • <p style=“padding: 15px; border-width: 1px solid black;”> This is a paragraph with a specified right padding.</p> • Output: This is a paragraph with a specified top padding. • Possible values: length in px, %.
  • 30. Padding and Margin Properties • Values for both the padding and the margin properties can be expressed using: • em (em values) • px (pixels) • mm (millimeters) • cm (centimeters) • in (inches) • % (percentage of the container element)