{ LearnWebSiteDesign.com }
HTML, XHTML CSS Tutorials and Free Website Templates
CSS Padding Properties Tutorials
The CSS padding properties define the space between the HTML element and the border of the HTML element. The padding takes on the background color of the HTML element.
You can set the padding of all 4 sides (top, right, bottom and left) of an HTML element can be set independently using seperate properties or you can use a shorthand padding property to set all of the 4 sides in one declaration.
The image below shows you where the padding is in relation to an HTML element, the margin and border.
Padding Values
The possible values of padding properties are listed below:
| length | Defines a fixed padding, for example: pixels, pt, em, etc. |
| % | Defines a padding in % of the containing element |
Setting Padding for Individual Sides
The padding properties for setting all 4 sides independantly are listed below:
| padding-top | Sets the top padding |
| padding-right | Sets the right padding |
| padding-bottom | Sets the bottom padding |
| padding-left | Sets the left padding |
The code example below shows you how to set the 4 sides individually using seperate padding properties. A solid, black colored border of 1 pixel and a background color of yellow has been applied to each paragraph tag to make it easier to distinguish the padding area.
The web page that the code example creates is here: CSS padding Properties Example.
Shorthand Padding Property
CSS allows you to set all padding properties in one declaration.
There are 4 ways to set the margin of all 4 sides using a shorthand padding property. The shorthand padding property can have from 1 to 4 values.
Shorthand Padding Property with 4 Values
The shorthand padding property example below has 4 values in the declaration. The first value (25px) is the top padding, the second vale (50px) is the right padding, the third (75px) is the bottom padding and last value (100px) is the left padding.
Shorthand Padding Property with 3 Values
The shorthand padding property example below has 3 values in the declaration. The first value (25px) is the top padding, the second value (50px) is the right padding and the left padding and the last value (100px) is the bottom padding.
Shorthand Padding Property with 2 Values
The shorthand padding propety example below has 2 values in the declaration. The first value (25px) is both the top padding and the bottom padding and the second value (100px) is the right padding and the left padding.
Shorthand Padding Property with 1 Value
The shorthand padding property example below has 1 in the declaration. The value (100px) is the padding for all 4 sides.
Tutorials
Templates
References
Sponsors
You can get your website online using Velnet, a leading UK web hosting provider. They provide free template and installation for WordPress blogs. Discuss webmaster related topics at Webmaster Serve, a Webmaster SEO forum
SouthernWebGroup.com provides high quality website design in Atlanta, GA as well as around the world.
Find low cost cheap website hosting and domain registration.
Browser our free no ads web hosting directory and find the free web hosting that's right for you and your budget.
Advertise your web design and web development related products and services here.
- Web Hosting UK
- Web Design Manchester
- Cheap Web Hosting
- free website hosting reviews
- ecommerce design
- Advertise
Recommended
Download free css web hosting templates that are easy to edit at FreeWebHostingTemplates.com.
Friends
- free web hosting templates
- free web hosting templates
- free web hosting reviews
- Web Development
- HD Wallpapers
- best web hosting providers
- Web Hosting Blog
- domain names
- iPage Host Reviews
- Reliable Bluehost Reviews
- Programming Forum
- Alojamento Web
- criar sites
- Free Facebook Banners
- Free No Ads Web Hosting Reviews
- Cheap Web Hosting Reviews
- Free Web Hosting Templates
- Free Premium Wordpress Themes
- Free Premium Wordpress Themes
- Free Joomla Template
- Free Wordpress Themes
- Best Android Apps
- Wordpress Themes Gallery
- Information technology courses
- Free PSD Files