SlideShare a Scribd company logo
1 of 23
Download to read offline
CSS
Padding
Prepared by:
Robilyn B. Pataras
Table of Contents
Definition
Individual Sides
Shorthand Property
Examples
01
02
03
04
Definition
01
Definition:
Padding is used to create space around
an element's content, inside of any
defined borders.
ABOUT
In CSS padding properties are used to create or
generate space around content. This is seen as
white space between the element content and the
element border.
When you set a padding value, it clears the area
around the content within the inside of the margin.
Understanding the Concept
02
Padding Sides
Padding Properties
CSS has properties for specifying the padding for
each side of an element:
❑ padding-top
❑ padding-right
❑ padding-bottom
❑ padding-left
All the padding properties can have the following values:
❑ 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
Note:
Negative values are not allowed and
invalid.
Note:
The default value of the CSS Padding
property is zero.
Shorthand
Property
03
❑ To shorten the code, it is possible to
specify all the padding properties in one
property.
Shorthand Property
The padding property is a shorthand property for
the following individual padding properties:
❑ padding-top
❑ padding-right
❑ padding-bottom
❑ padding-left
❑ If the padding property has three values:
Example - margin: 25px 50px 75px;
o top margin is 25px
o right and left margins are 50px
o bottom margin is 75px
❑ If the padding property has two values:
Example - margin: 25px 50px;
o top and bottom margins are 25px
o right and left margins are 50px
❑ If the padding property has one value:
Example - margin: 25px;
o all four margins are 25px
04
Examples
Padding Sides
Set different paddings for all four sides of a <div> element:
<!DOCTYPE html>
<html>
<head>
<style>
div {
padding-top: 50px;
padding-right: 30px;
padding-bottom: 50px;
padding-left: 80px;
}
</style>
</head>
<body>
<h2> Using individual padding properties</h2>
<div> This div element has a top padding of 50px, a right padding of
30px, a bottom padding of 50px, and a left padding of 80px.</div>
</body>
</html>
Output
Shorthand Property
Use the padding shorthand property with four values:
<!DOCTYPE html>
<html>
<head>
<style>
div {
border: 1px solid black;
padding: 25px 50px 75px 100px;
background-color: lightblue;
}
</style>
</head>
<body>
<h2> The padding shorthand property - 4 values </h2>
<div> This div element has a top padding of 25px, a right padding of
50px, a bottom padding of 75px, and a left padding of 100px.</div>
</body>
</html>
Output
—Martin Fowler
“Any fool can write code that
a computer can understand.
Good programmers write code
that humans can understand.”

More Related Content

Similar to Quarter 3_Lesson_One_CSSheets_Paddings.pdf

Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
ZahouAmel1
 
CSS, CSS Selectors, CSS Box Model
CSS, CSS Selectors, CSS Box ModelCSS, CSS Selectors, CSS Box Model
CSS, CSS Selectors, CSS Box Model
jamiecavanaugh
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
Senthil Kumar
 

Similar to Quarter 3_Lesson_One_CSSheets_Paddings.pdf (20)

CSS Cascade Style Sheet
CSS Cascade Style SheetCSS Cascade Style Sheet
CSS Cascade Style Sheet
 
Css
CssCss
Css
 
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvvLecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
Lecture 10 CSS part 2.pptxvvvvvvvvvvvvvv
 
Web Layout
Web LayoutWeb Layout
Web Layout
 
CSS Walktrough Internship Course
CSS Walktrough Internship CourseCSS Walktrough Internship Course
CSS Walktrough Internship Course
 
Working-With-The-Box-Model-Lesson-5.pptx
Working-With-The-Box-Model-Lesson-5.pptxWorking-With-The-Box-Model-Lesson-5.pptx
Working-With-The-Box-Model-Lesson-5.pptx
 
Cascading style sheets (CSS-Web Technology)
Cascading style sheets (CSS-Web Technology)Cascading style sheets (CSS-Web Technology)
Cascading style sheets (CSS-Web Technology)
 
CSS3: Background And DropShadows:
CSS3: Background And DropShadows:CSS3: Background And DropShadows:
CSS3: Background And DropShadows:
 
Dimensions of elements.pdf
Dimensions of elements.pdfDimensions of elements.pdf
Dimensions of elements.pdf
 
CSS.pdf
CSS.pdfCSS.pdf
CSS.pdf
 
Css
CssCss
Css
 
Css
CssCss
Css
 
Css3
Css3Css3
Css3
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
 
Web Development - Lecture 6
Web Development - Lecture 6Web Development - Lecture 6
Web Development - Lecture 6
 
Margin
MarginMargin
Margin
 
CSS, CSS Selectors, CSS Box Model
CSS, CSS Selectors, CSS Box ModelCSS, CSS Selectors, CSS Box Model
CSS, CSS Selectors, CSS Box Model
 
Cascading Style Sheets
Cascading Style SheetsCascading Style Sheets
Cascading Style Sheets
 
Web Programming& Scripting Lab
Web Programming& Scripting LabWeb Programming& Scripting Lab
Web Programming& Scripting Lab
 
CSS
CSSCSS
CSS
 

Recently uploaded

Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
FIDO Alliance
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 

Recently uploaded (20)

Google I/O Extended 2024 Warsaw
Google I/O Extended 2024 WarsawGoogle I/O Extended 2024 Warsaw
Google I/O Extended 2024 Warsaw
 
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
AI+A11Y 11MAY2024 HYDERBAD GAAD 2024 - HelloA11Y (11 May 2024)
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
Introduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDMIntroduction to use of FHIR Documents in ABDM
Introduction to use of FHIR Documents in ABDM
 
ERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage IntacctERP Contender Series: Acumatica vs. Sage Intacct
ERP Contender Series: Acumatica vs. Sage Intacct
 
Vector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptxVector Search @ sw2con for slideshare.pptx
Vector Search @ sw2con for slideshare.pptx
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptxCyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
Cyber Insurance - RalphGilot - Embry-Riddle Aeronautical University.pptx
 
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdfFrisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
Frisco Automating Purchase Orders with MuleSoft IDP- May 10th, 2024.pptx.pdf
 
State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!State of the Smart Building Startup Landscape 2024!
State of the Smart Building Startup Landscape 2024!
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
JavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate GuideJavaScript Usage Statistics 2024 - The Ultimate Guide
JavaScript Usage Statistics 2024 - The Ultimate Guide
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Oauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoftOauth 2.0 Introduction and Flows with MuleSoft
Oauth 2.0 Introduction and Flows with MuleSoft
 
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
Observability Concepts EVERY Developer Should Know (DevOpsDays Seattle)
 
Intro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptxIntro to Passkeys and the State of Passwordless.pptx
Intro to Passkeys and the State of Passwordless.pptx
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 

Quarter 3_Lesson_One_CSSheets_Paddings.pdf

  • 2. Table of Contents Definition Individual Sides Shorthand Property Examples 01 02 03 04
  • 4. Definition: Padding is used to create space around an element's content, inside of any defined borders.
  • 5. ABOUT In CSS padding properties are used to create or generate space around content. This is seen as white space between the element content and the element border. When you set a padding value, it clears the area around the content within the inside of the margin.
  • 8. Padding Properties CSS has properties for specifying the padding for each side of an element: ❑ padding-top ❑ padding-right ❑ padding-bottom ❑ padding-left
  • 9. All the padding properties can have the following values: ❑ 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
  • 10. Note: Negative values are not allowed and invalid.
  • 11. Note: The default value of the CSS Padding property is zero.
  • 13. ❑ To shorten the code, it is possible to specify all the padding properties in one property.
  • 14. Shorthand Property The padding property is a shorthand property for the following individual padding properties: ❑ padding-top ❑ padding-right ❑ padding-bottom ❑ padding-left
  • 15. ❑ If the padding property has three values: Example - margin: 25px 50px 75px; o top margin is 25px o right and left margins are 50px o bottom margin is 75px
  • 16. ❑ If the padding property has two values: Example - margin: 25px 50px; o top and bottom margins are 25px o right and left margins are 50px
  • 17. ❑ If the padding property has one value: Example - margin: 25px; o all four margins are 25px
  • 19. Padding Sides Set different paddings for all four sides of a <div> element: <!DOCTYPE html> <html> <head> <style> div { padding-top: 50px; padding-right: 30px; padding-bottom: 50px; padding-left: 80px; } </style> </head> <body> <h2> Using individual padding properties</h2> <div> This div element has a top padding of 50px, a right padding of 30px, a bottom padding of 50px, and a left padding of 80px.</div> </body> </html>
  • 21. Shorthand Property Use the padding shorthand property with four values: <!DOCTYPE html> <html> <head> <style> div { border: 1px solid black; padding: 25px 50px 75px 100px; background-color: lightblue; } </style> </head> <body> <h2> The padding shorthand property - 4 values </h2> <div> This div element has a top padding of 25px, a right padding of 50px, a bottom padding of 75px, and a left padding of 100px.</div> </body> </html>
  • 23. —Martin Fowler “Any fool can write code that a computer can understand. Good programmers write code that humans can understand.”