CSS Tutorial
Padding is a CSS property that adds space inside an element, creating separation between the content and the borders. It can be applied to all four sides of an element: top, right, bottom, and left.
padding
property: Set the padding
property to the desired amount of space.top
, right
, bottom
, left
) to specify the side(s) you want to add padding to./* Add 10 pixels of padding to all sides of the paragraph element */
p {
padding: 10px;
}
/* Add different padding values to each side of the div element */
div {
padding: 10px 20px 30px 40px;
}
Padding can improve accessibility by increasing the spacing between elements, making it easier for users to navigate and read content. It can also create visual separation between different sections of a page, enhancing the user experience.
By following these simple steps, you can effectively add padding to HTML elements, enhancing the design and accessibility of your website.