CSS Properties: How to set the right padding for a paragraph element
Solution:
HTML Code:
Explanation:
- This HTML document demonstrates how to set right padding for paragraph elements using CSS.
- CSS comments are added to explain each section of the code.
- Two CSS rules are defined:
- p.w3r: Applies to paragraphs with the class "w3r" and sets the right padding to 3 centimeters.
- p.w3r1: Applies to paragraphs with the class "w3r1" and sets the right padding to 20% of the width of its containing block.
- Paragraph elements with different classes are used to demonstrate the application of different padding styles.
Live Demo:
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics