CSS Padding

 


  • CSS works on a box model structure, where elements are packed according to the sequence of the image
  • The padding property defines the space between the element and the border
  • The background color isn’t affected in the case of padding
  • You can also add padding individually to each corner: Top, Bottom, Left and Right.
index.html

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>padding</title>
    <link rel="stylesheet" href="style.css">
</head>

<body>
    <div>
        <h1>padding Property</h1>
    </div>
</body>

</html>


style.css
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: lightblue;
}

div {
    width: 300px;
    margin: auto;
    border: 2px solid red;
}

div h1 {
    padding: 30px 20px;
    background-color: brown;
}



Output:








Related Posts:

  • CSS Height, Width and Max-widthThe CSS height and width properties are used to set the height and width of an element.The CSS max-width property is used to set the maximum width of … Read More
  • CSS BordersBorder property helps in creating borders around the textCSS border properties allow you to specify the style, width, and color of an element's border… Read More
  • CSS Padding CSS works on a box model structure, where elements are packed according to the sequence of the imageThe padding property defines the space betwe… Read More
  • CSS Box Model  In CSS, the term "box model" is used when talking about design and layout.The CSS box model is essentially a box that wraps around every H… Read More
  • CSS Margin CSS MarginsMargins are used to create space around elements, outside of any defined bordersWith CSS, you have full control over the margins. The… Read More

0 Comments:

Post a Comment

Do leave your comments