SlideShare une entreprise Scribd logo
1  sur  20
Web Programming
SYED SHAHZAIB SOHAIL
Lecture 6
CSS Basics
Contents
• CSS Colors
• CSS Backgrounds
• CSS Margins
• CSS Padding
• CSS Height/Width
CSS Colors
• Colors are specified using predefined color names or RGB, HEX, RGBA, HSL,
HSLA values.
• In HTML, a color can be specified by using a color name.
Continued…
• Background Color
• You can set the background color for HTML element
<h1 style=“background-color: red;”>HelloWorld</p>
<p style=“background-color: tomato;”>Paragraph</p>
• Text Color
• You can set the color of text
<h1 style=“color: green;”>HelloWorld</p>
<p style=“color: tomato;”>Paragraph</p>
Continued…
• Border Color
• You can set the color of borders
<h1 style=“border-color: DodgerBlue;”>Hello World</p>
<p style=“border-color: tomato;”>Paragraph</p>
• ColorValues
• In HTML, colors can also be specified using RGB, HEX , RGBA, HSL, HSLA values
• Same as color name “Tomato”:
• Rgb(255, 99, 71), #ff6347, hsl(9, 100%, 64%)
• Rgba(255, 99, 71, 0.5), hsla(9, 100%, 64%, 0.5)
CSS Backgrounds
• The CSS background properties are used to define the background effects for
elements.
• CSS Background properties:
• background-color
• background-image
• background-repeat
• background-attachment
• background-position
Continued…
• BackgroundColor
• The background-color property specifies the background color of an element
• Background Image
• The background-image property specifies an image to use as the background of an
element
• By default, the image is repeated so it covers the entire element
Continued…
• Background Image – Repeat Horizontally orVertically
• By default, the background-image property repeats an image both horizontally and
vertically
• Some images should be repeated horizontally or vertically or they will look strange.
• Background-repeat property has following values:
• repeat
• repeat-x
• repeat-y
• no-repeat
Continued…
• Background Image – Set Position
• The background-position property is used to specify the position of the background
image
• Background-position property has following values
• Top
• Right
• Bottom
• Left
Continued…
• Background Image – Fixed or Scroll?
• The background-attachment property specifies whether the background image should
scroll or be fixed
Continued…
• Background – Shorthand property
• The shorthand property for background is background
background: background-color, background-image, background-repeat, background-attachment,
background-position;
CSS Margins
• The CSS margin property is 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, left)
• CSS has properties for specifying the margin for each side of an element:
• margin-top
• margin-right
• margin-bottom
• margin-left
Continued…
• All the margin properties can have the following values:
• auto – the browser calculates the margin
• length – specifies a margin in px, pt, cm etc
• % - specifies a margin in % of the width of the containing element
• inherit – specifies that the margin should be inherited from the parent element
• Margin – Shorthand Property
• The margin property is a shorthand property for all individual margin properties
margin: 100px 50px 75px 100px;
margin: 100px 50px 75px;
margin: 25px 100px;
margin: 50px;
Continued…
• The auto value
• You can set the margin property to auto to horizontally center the element within its
container
• The element will then take up the specified width and the remaining space will be split
equally between the left and right margins
• 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 doesn’t happen on left and right margins
CSS Padding
• The CSS padding property is 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, left)
• CSS has properties for specifying the padding for each side of element
• padding-top
• padding-right
• padding-bottom
• padding-left
Continued…
• All the padding properties can have the following values:
• auto – the browser calculates the padding
• length – specifies a padding in px, pt, cm etc
• % - specifies a padding in % of the width of the containing element
• inherit – specifies that the padding should be inherited from the parent element
• Padding – Shorthand Property
• The padding property is a shorthand property for all individual padding properties
padding: 100px 50px 75px 100px;
padding: 100px 50px 75px;
padding: 25px 100px;
padding: 50px;
Continued…
• Padding and Element Width
• The CSS width property specifies the width of the element’s content area
• The content area is the portion inside the padding, border and margin of an element
• So, if an element has a specified width, the padding added to that element will be added to
the total width of the element
div {width: 100px; padding: 25px;}
• To keep the width at 100px, no matter the amount of padding, you can use the box-sizing
property.This causes the element to maintain its width; if you increase the padding the
available content space will decrease
div {width: 100px; padding: 25px; box-sizing: border-box;}
CSS Height/Width
• Used to set the height & width of an element
• Height & width can be set to auto (browser calculates the height & width)
• Height & width can be defined in terms of px, %, cm etc
• Note: The height & width properties do not include padding, borders or
margins
Continued…
• There are some height/width properties namely
• max-height (sets the maximum height of an element)
• max-width (sets the maximum width of an element)
• min-height (sets the minimum height of an element)
• min-width (sets the minimum width of an element)
• All the properties can be set as auto, px, %, cm etc

Contenu connexe

Tendances

1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introduction
apnwebdev
 

Tendances (19)

Css
CssCss
Css
 
Cascading style sheets - CSS
Cascading style sheets - CSSCascading style sheets - CSS
Cascading style sheets - CSS
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
 
CSS 101
CSS 101CSS 101
CSS 101
 
Cascading Style Sheets(CSS)
Cascading Style Sheets(CSS)Cascading Style Sheets(CSS)
Cascading Style Sheets(CSS)
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
CSS tutorial chapter 3
CSS tutorial chapter 3CSS tutorial chapter 3
CSS tutorial chapter 3
 
CSS tutorial chapter 2
CSS tutorial chapter 2CSS tutorial chapter 2
CSS tutorial chapter 2
 
Css
CssCss
Css
 
Css types internal, external and inline (1)
Css types internal, external and inline (1)Css types internal, external and inline (1)
Css types internal, external and inline (1)
 
CSS Basics part One
CSS Basics part OneCSS Basics part One
CSS Basics part One
 
1 03 - CSS Introduction
1 03 - CSS Introduction1 03 - CSS Introduction
1 03 - CSS Introduction
 
Cascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) helpCascading Style Sheets (CSS) help
Cascading Style Sheets (CSS) help
 
Beginners css tutorial for web designers
Beginners css tutorial for web designersBeginners css tutorial for web designers
Beginners css tutorial for web designers
 
CSS Basic Introduction, Rules, And Tips
CSS Basic Introduction, Rules, And TipsCSS Basic Introduction, Rules, And Tips
CSS Basic Introduction, Rules, And Tips
 
uptu web technology unit 2 Css
uptu web technology unit 2 Cssuptu web technology unit 2 Css
uptu web technology unit 2 Css
 
CSS
CSSCSS
CSS
 
Css
CssCss
Css
 
CSS Basics (Cascading Style Sheet)
CSS Basics (Cascading Style Sheet)CSS Basics (Cascading Style Sheet)
CSS Basics (Cascading Style Sheet)
 

Similaire à Web Development - Lecture 6

Castro Chapter 11
Castro Chapter 11Castro Chapter 11
Castro Chapter 11
Jeff Byrnes
 
W3Conf slides - The top web features from caniuse.com you can use today
W3Conf slides - The top web features from caniuse.com you can use todayW3Conf slides - The top web features from caniuse.com you can use today
W3Conf slides - The top web features from caniuse.com you can use today
adeveria
 

Similaire à Web Development - Lecture 6 (20)

Css
CssCss
Css
 
Dimensions of elements.pdf
Dimensions of elements.pdfDimensions of elements.pdf
Dimensions of elements.pdf
 
Cascading style sheet part 2
Cascading style sheet   part 2Cascading style sheet   part 2
Cascading style sheet part 2
 
Unit - 3 CSS(Cascading Style Sheet).pptx
Unit - 3 CSS(Cascading Style Sheet).pptxUnit - 3 CSS(Cascading Style Sheet).pptx
Unit - 3 CSS(Cascading Style Sheet).pptx
 
CSS for basic learner
CSS for basic learnerCSS for basic learner
CSS for basic learner
 
Intro to html, css & sass
Intro to html, css & sassIntro to html, css & sass
Intro to html, css & sass
 
Flexbox, Grid and Sass
Flexbox, Grid and SassFlexbox, Grid and Sass
Flexbox, Grid and Sass
 
Castro Chapter 11
Castro Chapter 11Castro Chapter 11
Castro Chapter 11
 
CSS
CSSCSS
CSS
 
css3.pptx
css3.pptxcss3.pptx
css3.pptx
 
CSS Cascade Style Sheet
CSS Cascade Style SheetCSS Cascade Style Sheet
CSS Cascade Style Sheet
 
CSS and Layout
CSS and LayoutCSS and Layout
CSS and Layout
 
CSS
CSSCSS
CSS
 
Css3
Css3Css3
Css3
 
Unit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptxUnit-3-CSS-BWT.pptx
Unit-3-CSS-BWT.pptx
 
BITM3730 9-20.pptx
BITM3730 9-20.pptxBITM3730 9-20.pptx
BITM3730 9-20.pptx
 
BITM3730 9-19.pptx
BITM3730 9-19.pptxBITM3730 9-19.pptx
BITM3730 9-19.pptx
 
W3Conf slides - The top web features from caniuse.com you can use today
W3Conf slides - The top web features from caniuse.com you can use todayW3Conf slides - The top web features from caniuse.com you can use today
W3Conf slides - The top web features from caniuse.com you can use today
 
Css intro
Css introCss intro
Css intro
 
CSS
CSSCSS
CSS
 

Dernier

Simple Conference Style Presentation by Slidesgo.pptx
Simple Conference Style Presentation by Slidesgo.pptxSimple Conference Style Presentation by Slidesgo.pptx
Simple Conference Style Presentation by Slidesgo.pptx
balqisyamutia
 
ab-initio-training basics and architecture
ab-initio-training basics and architectureab-initio-training basics and architecture
ab-initio-training basics and architecture
saipriyacoool
 
Resume all my skills and educations and achievement
Resume all my skills and educations and  achievement Resume all my skills and educations and  achievement
Resume all my skills and educations and achievement
210303105569
 
How to Build a Simple Shopify Website
How to Build a Simple Shopify WebsiteHow to Build a Simple Shopify Website
How to Build a Simple Shopify Website
mark11275
 
Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...
gajnagarg
 
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
CristineGraceAcuyan
 
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
eeanqy
 
怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证
怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证
怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证
eeanqy
 
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
yhavx
 
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
eqaqen
 
Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...
nirzagarg
 
怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证
怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证
怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证
ehyxf
 

Dernier (20)

Independent Escorts Goregaon WhatsApp +91-9930687706, Best Service
Independent Escorts Goregaon WhatsApp +91-9930687706, Best ServiceIndependent Escorts Goregaon WhatsApp +91-9930687706, Best Service
Independent Escorts Goregaon WhatsApp +91-9930687706, Best Service
 
Simple Conference Style Presentation by Slidesgo.pptx
Simple Conference Style Presentation by Slidesgo.pptxSimple Conference Style Presentation by Slidesgo.pptx
Simple Conference Style Presentation by Slidesgo.pptx
 
ab-initio-training basics and architecture
ab-initio-training basics and architectureab-initio-training basics and architecture
ab-initio-training basics and architecture
 
Resume all my skills and educations and achievement
Resume all my skills and educations and  achievement Resume all my skills and educations and  achievement
Resume all my skills and educations and achievement
 
How to Build a Simple Shopify Website
How to Build a Simple Shopify WebsiteHow to Build a Simple Shopify Website
How to Build a Simple Shopify Website
 
Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...
Top profile Call Girls In Mysore [ 7014168258 ] Call Me For Genuine Models We...
 
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
Q4-Trends-Networks-Module-3.pdfqquater days sheets123456789
 
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
怎样办理伦敦国王学院毕业证(KCL毕业证书)成绩单留信认证
 
怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证
怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证
怎样办理巴斯大学毕业证(Bath毕业证书)成绩单留信认证
 
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
一比一原版(ANU毕业证书)澳大利亚国立大学毕业证原件一模一样
 
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
一比一定(购)西悉尼大学毕业证(WSU毕业证)成绩单学位证
 
Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...
Top profile Call Girls In Sonipat [ 7014168258 ] Call Me For Genuine Models W...
 
TRose UXPA Experience Design Concord .pptx
TRose UXPA Experience Design Concord .pptxTRose UXPA Experience Design Concord .pptx
TRose UXPA Experience Design Concord .pptx
 
怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证
怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证
怎样办理莫纳什大学毕业证(Monash毕业证书)成绩单留信认证
 
Raebareli Girl Whatsapp Number 📞 8617370543 | Girls Number for Friendship
Raebareli Girl Whatsapp Number 📞 8617370543 | Girls Number for FriendshipRaebareli Girl Whatsapp Number 📞 8617370543 | Girls Number for Friendship
Raebareli Girl Whatsapp Number 📞 8617370543 | Girls Number for Friendship
 
Hackathon evaluation template_latest_uploadpdf
Hackathon evaluation template_latest_uploadpdfHackathon evaluation template_latest_uploadpdf
Hackathon evaluation template_latest_uploadpdf
 
Essential UI/UX Design Principles: A Comprehensive Guide
Essential UI/UX Design Principles: A Comprehensive GuideEssential UI/UX Design Principles: A Comprehensive Guide
Essential UI/UX Design Principles: A Comprehensive Guide
 
Gamestore case study UI UX by Amgad Ibrahim
Gamestore case study UI UX by Amgad IbrahimGamestore case study UI UX by Amgad Ibrahim
Gamestore case study UI UX by Amgad Ibrahim
 
Sweety Planet Packaging Design Process Book.pptx
Sweety Planet Packaging Design Process Book.pptxSweety Planet Packaging Design Process Book.pptx
Sweety Planet Packaging Design Process Book.pptx
 
Q4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentationQ4-W4-SCIENCE-5 power point presentation
Q4-W4-SCIENCE-5 power point presentation
 

Web Development - Lecture 6

  • 3. Contents • CSS Colors • CSS Backgrounds • CSS Margins • CSS Padding • CSS Height/Width
  • 4. CSS Colors • Colors are specified using predefined color names or RGB, HEX, RGBA, HSL, HSLA values. • In HTML, a color can be specified by using a color name.
  • 5. Continued… • Background Color • You can set the background color for HTML element <h1 style=“background-color: red;”>HelloWorld</p> <p style=“background-color: tomato;”>Paragraph</p> • Text Color • You can set the color of text <h1 style=“color: green;”>HelloWorld</p> <p style=“color: tomato;”>Paragraph</p>
  • 6. Continued… • Border Color • You can set the color of borders <h1 style=“border-color: DodgerBlue;”>Hello World</p> <p style=“border-color: tomato;”>Paragraph</p> • ColorValues • In HTML, colors can also be specified using RGB, HEX , RGBA, HSL, HSLA values • Same as color name “Tomato”: • Rgb(255, 99, 71), #ff6347, hsl(9, 100%, 64%) • Rgba(255, 99, 71, 0.5), hsla(9, 100%, 64%, 0.5)
  • 7. CSS Backgrounds • The CSS background properties are used to define the background effects for elements. • CSS Background properties: • background-color • background-image • background-repeat • background-attachment • background-position
  • 8. Continued… • BackgroundColor • The background-color property specifies the background color of an element • Background Image • The background-image property specifies an image to use as the background of an element • By default, the image is repeated so it covers the entire element
  • 9. Continued… • Background Image – Repeat Horizontally orVertically • By default, the background-image property repeats an image both horizontally and vertically • Some images should be repeated horizontally or vertically or they will look strange. • Background-repeat property has following values: • repeat • repeat-x • repeat-y • no-repeat
  • 10. Continued… • Background Image – Set Position • The background-position property is used to specify the position of the background image • Background-position property has following values • Top • Right • Bottom • Left
  • 11. Continued… • Background Image – Fixed or Scroll? • The background-attachment property specifies whether the background image should scroll or be fixed
  • 12. Continued… • Background – Shorthand property • The shorthand property for background is background background: background-color, background-image, background-repeat, background-attachment, background-position;
  • 13. CSS Margins • The CSS margin property is 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, left) • CSS has properties for specifying the margin for each side of an element: • margin-top • margin-right • margin-bottom • margin-left
  • 14. Continued… • All the margin properties can have the following values: • auto – the browser calculates the margin • length – specifies a margin in px, pt, cm etc • % - specifies a margin in % of the width of the containing element • inherit – specifies that the margin should be inherited from the parent element • Margin – Shorthand Property • The margin property is a shorthand property for all individual margin properties margin: 100px 50px 75px 100px; margin: 100px 50px 75px; margin: 25px 100px; margin: 50px;
  • 15. Continued… • The auto value • You can set the margin property to auto to horizontally center the element within its container • The element will then take up the specified width and the remaining space will be split equally between the left and right margins • 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 doesn’t happen on left and right margins
  • 16. CSS Padding • The CSS padding property is 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, left) • CSS has properties for specifying the padding for each side of element • padding-top • padding-right • padding-bottom • padding-left
  • 17. Continued… • All the padding properties can have the following values: • auto – the browser calculates the padding • length – specifies a padding in px, pt, cm etc • % - specifies a padding in % of the width of the containing element • inherit – specifies that the padding should be inherited from the parent element • Padding – Shorthand Property • The padding property is a shorthand property for all individual padding properties padding: 100px 50px 75px 100px; padding: 100px 50px 75px; padding: 25px 100px; padding: 50px;
  • 18. Continued… • Padding and Element Width • The CSS width property specifies the width of the element’s content area • The content area is the portion inside the padding, border and margin of an element • So, if an element has a specified width, the padding added to that element will be added to the total width of the element div {width: 100px; padding: 25px;} • To keep the width at 100px, no matter the amount of padding, you can use the box-sizing property.This causes the element to maintain its width; if you increase the padding the available content space will decrease div {width: 100px; padding: 25px; box-sizing: border-box;}
  • 19. CSS Height/Width • Used to set the height & width of an element • Height & width can be set to auto (browser calculates the height & width) • Height & width can be defined in terms of px, %, cm etc • Note: The height & width properties do not include padding, borders or margins
  • 20. Continued… • There are some height/width properties namely • max-height (sets the maximum height of an element) • max-width (sets the maximum width of an element) • min-height (sets the minimum height of an element) • min-width (sets the minimum width of an element) • All the properties can be set as auto, px, %, cm etc