SlideShare a Scribd company logo
2
Most read
4
Most read
12
Most read
CSS - Backgrounds
This chapter teaches you how to set backgrounds of various HTML
elements. You can set the following background properties of an
element −
•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.
•The background property is used as a shorthand to specify a number of other
background properties.
Set the Background Color
Following is the example which demonstrates how to set the background color
for an element.
<html>
<head>
</head>
<body>
<p style = "background-color:yellow;">
This text has a yellow background color.
</p>
</body>
</html>
Set the Background Image
We can set the background image by calling local stored images as shown below
<html>
<head>
<style>
body {
background-image: url("/css/images/css.jpg");
background-color: #cccccc;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
</body>
<html>
Repeat the Background Image
The following example demonstrates how to repeat the background image if an
image is small. You can use no-repeat value for background-repeat property if
you don't want to repeat an image, in this case image will display only once.
By default background-repeat property will have repeat value.
<html>
<head>
<style>
body {
background-image: url("/css/images/css.jpg");
background-repeat: repeat;
}
</style>
</head>
<body>
<p>Texamine</p>
</body>
</html>
<html>
<head>
<style>
body {
background-image: url("/css/images/css.jpg");
background-repeat: repeat-y;
}
</style>
</head>
<body>
<p>Texamine</p>
</body>
</html>
<html>
<head>
<style>
body {
background-image: url("/css/images/css.jpg");
background-repeat: repeat-x;
}
</style>
</head>
<body>
<p>Texamine</p>
</body>
</html>
Set the Background Image Position
The following example demonstrates how to set the background image position
100 pixels away from the left side.
<html>
<head>
<style>
body {
background-image: url("/css/images/css.jpg");
background-position:100px;
}
</style>
</head>
<body>
<p>Texamine</p>
</body>
</html>
The following example demonstrates how to set the background image position 100
pixels away from the left side and 200 pixels down from the top.
<html>
<head>
<style>
body {
background-image: url("/css/images/css.jpg");
background-position:100px 200px; }
</style>
</head>
<body>
<p>Texamine</p>
</body>
</html>
Set the Background Attachment
Background attachment determines whether a background image is fixed or
scrolls with the rest of the page.
The following example demonstrates how to set the fixed background image.
<!DOCTYPE html>
<html>
<head>
<style>
body {
background-image: url('/css/images/css.jpg');
background-repeat: no-repeat;
background-attachment: fixed;
}
</style>
</head>
<body>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
<p>The background-image is fixed. Try to scroll down the page.</p>
</body>
</html>
Css   backgrounds

More Related Content

PPTX
PDF
Background property in css
PPT
Introduction to CSS Borders - Lesson 4
PPTX
CSS - Text Properties
PDF
Intro to HTML and CSS basics
PPT
How Cascading Style Sheets (CSS) Works
PPTX
Css tables
Background property in css
Introduction to CSS Borders - Lesson 4
CSS - Text Properties
Intro to HTML and CSS basics
How Cascading Style Sheets (CSS) Works
Css tables

What's hot (20)

PPT
CSS Basics
PPTX
Css ppt
PPTX
Css selectors
PPT
Introduction to Cascading Style Sheets (CSS)
PPTX
Css borders
PPTX
Flex box
PPT
Advanced Cascading Style Sheets
PPTX
PPTX
Css position
PPTX
Css pseudo-classes
PDF
Introduction to CSS
PPTX
Css Text Formatting
PDF
HTML & CSS Masterclass
PPT
PPTX
PPTX
HTML, CSS and Java Scripts Basics
PPTX
HTML (Web) basics for a beginner
PPT
Css lecture notes
PPTX
Html links
CSS Basics
Css ppt
Css selectors
Introduction to Cascading Style Sheets (CSS)
Css borders
Flex box
Advanced Cascading Style Sheets
Css position
Css pseudo-classes
Introduction to CSS
Css Text Formatting
HTML & CSS Masterclass
HTML, CSS and Java Scripts Basics
HTML (Web) basics for a beginner
Css lecture notes
Html links
Ad

Similar to Css backgrounds (20)

PPTX
Cascading Style Sheets Background .pptx
PDF
Background
PPTX
Css color and background properties
PPTX
Presentation-1-1.pptx
DOCX
INTERNET PROGRAMMING UNIT I REMAINING -SECOND HALF.docx
PDF
CSS3 Backgrounds
PDF
CSS - Adding Background Images
PPTX
CSS Topic wise Short notes ppt by Navya.E
PDF
Css background image
PDF
HTML ,CSS ,JQuery Cheat Sheet
PPTX
Css3 Complete Reference
PPTX
Unit 2 Internet and web technology CSS report
PDF
Css Examples
PDF
cascading stylesheet_cssppt-100604051600-phpapp02.pdf
PPTX
Web Development - Lecture 6
PPTX
Unit - 3 CSS(Cascading Style Sheet).pptx
PPTX
uptu web technology unit 2 Css
PDF
9781305503922t4-200824144338 (2).pdf
Cascading Style Sheets Background .pptx
Background
Css color and background properties
Presentation-1-1.pptx
INTERNET PROGRAMMING UNIT I REMAINING -SECOND HALF.docx
CSS3 Backgrounds
CSS - Adding Background Images
CSS Topic wise Short notes ppt by Navya.E
Css background image
HTML ,CSS ,JQuery Cheat Sheet
Css3 Complete Reference
Unit 2 Internet and web technology CSS report
Css Examples
cascading stylesheet_cssppt-100604051600-phpapp02.pdf
Web Development - Lecture 6
Unit - 3 CSS(Cascading Style Sheet).pptx
uptu web technology unit 2 Css
9781305503922t4-200824144338 (2).pdf
Ad

More from AbhishekMondal42 (20)

PPTX
Oss evaluation-certification-oss-financial-advantages
PPTX
Word press 01
PPTX
Word press posts(preview &amp; publish)
PPTX
Word press posts(add , edit , delete post)
PPTX
Word press pages(edit and delete)
PPTX
Word press pages(add)
PPTX
Word press media(add,insert,delete)
PPTX
Word press media library
PPTX
Word press widget management
PPTX
Word press view plugins
PPTX
Word press user roles
PPTX
Word press theme management
PPTX
Word press personal profile
PPTX
Word press moderate comments
PPTX
Word press install plugins
PPTX
Word press edit users
PPTX
Word press edit tags
PPTX
Word press edit links
PPTX
Word press edit comments
PPTX
Word press delete users
Oss evaluation-certification-oss-financial-advantages
Word press 01
Word press posts(preview &amp; publish)
Word press posts(add , edit , delete post)
Word press pages(edit and delete)
Word press pages(add)
Word press media(add,insert,delete)
Word press media library
Word press widget management
Word press view plugins
Word press user roles
Word press theme management
Word press personal profile
Word press moderate comments
Word press install plugins
Word press edit users
Word press edit tags
Word press edit links
Word press edit comments
Word press delete users

Recently uploaded (20)

PDF
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
PDF
Types of Literary Text: Poetry and Prose
PDF
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
PDF
O7-L3 Supply Chain Operations - ICLT Program
PDF
The Final Stretch: How to Release a Game and Not Die in the Process.
PDF
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
PPTX
Week 4 Term 3 Study Techniques revisited.pptx
PPTX
Revamp in MTO Odoo 18 Inventory - Odoo Slides
PPTX
Introduction and Scope of Bichemistry.pptx
PPTX
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
LDMMIA Reiki Yoga Workshop 15 MidTerm Review
PPTX
How to Manage Starshipit in Odoo 18 - Odoo Slides
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
NOI Hackathon - Summer Edition - GreenThumber.pptx
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PDF
English Language Teaching from Post-.pdf
LDMMIA Reiki Yoga S2 L3 Vod Sample Preview
Types of Literary Text: Poetry and Prose
Piense y hagase Rico - Napoleon Hill Ccesa007.pdf
O7-L3 Supply Chain Operations - ICLT Program
The Final Stretch: How to Release a Game and Not Die in the Process.
Origin of periodic table-Mendeleev’s Periodic-Modern Periodic table
human mycosis Human fungal infections are called human mycosis..pptx
Introduction_to_Human_Anatomy_and_Physiology_for_B.Pharm.pptx
Week 4 Term 3 Study Techniques revisited.pptx
Revamp in MTO Odoo 18 Inventory - Odoo Slides
Introduction and Scope of Bichemistry.pptx
The Healthy Child – Unit II | Child Health Nursing I | B.Sc Nursing 5th Semester
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
LDMMIA Reiki Yoga Workshop 15 MidTerm Review
How to Manage Starshipit in Odoo 18 - Odoo Slides
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
102 student loan defaulters named and shamed – Is someone you know on the list?
NOI Hackathon - Summer Edition - GreenThumber.pptx
Abdominal Access Techniques with Prof. Dr. R K Mishra
English Language Teaching from Post-.pdf

Css backgrounds

  • 2. This chapter teaches you how to set backgrounds of various HTML elements. You can set the following background properties of an element − •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. •The background property is used as a shorthand to specify a number of other background properties.
  • 3. Set the Background Color Following is the example which demonstrates how to set the background color for an element. <html> <head> </head> <body> <p style = "background-color:yellow;"> This text has a yellow background color. </p> </body> </html>
  • 4. Set the Background Image We can set the background image by calling local stored images as shown below <html> <head> <style> body { background-image: url("/css/images/css.jpg"); background-color: #cccccc; } </style> </head> <body> <h1>Hello World!</h1> </body> <html>
  • 5. Repeat the Background Image The following example demonstrates how to repeat the background image if an image is small. You can use no-repeat value for background-repeat property if you don't want to repeat an image, in this case image will display only once. By default background-repeat property will have repeat value.
  • 6. <html> <head> <style> body { background-image: url("/css/images/css.jpg"); background-repeat: repeat; } </style> </head> <body> <p>Texamine</p> </body> </html>
  • 7. <html> <head> <style> body { background-image: url("/css/images/css.jpg"); background-repeat: repeat-y; } </style> </head> <body> <p>Texamine</p> </body> </html>
  • 8. <html> <head> <style> body { background-image: url("/css/images/css.jpg"); background-repeat: repeat-x; } </style> </head> <body> <p>Texamine</p> </body> </html>
  • 9. Set the Background Image Position The following example demonstrates how to set the background image position 100 pixels away from the left side. <html> <head> <style> body { background-image: url("/css/images/css.jpg"); background-position:100px; } </style> </head> <body> <p>Texamine</p> </body> </html>
  • 10. The following example demonstrates how to set the background image position 100 pixels away from the left side and 200 pixels down from the top. <html> <head> <style> body { background-image: url("/css/images/css.jpg"); background-position:100px 200px; } </style> </head> <body> <p>Texamine</p> </body> </html>
  • 11. Set the Background Attachment Background attachment determines whether a background image is fixed or scrolls with the rest of the page. The following example demonstrates how to set the fixed background image.
  • 12. <!DOCTYPE html> <html> <head> <style> body { background-image: url('/css/images/css.jpg'); background-repeat: no-repeat; background-attachment: fixed; } </style> </head> <body> <p>The background-image is fixed. Try to scroll down the page.</p> <p>The background-image is fixed. Try to scroll down the page.</p> <p>The background-image is fixed. Try to scroll down the page.</p> <p>The background-image is fixed. Try to scroll down the page.</p> </body> </html>