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 Combinators It explains the relation between multiple or single selectors. There are four major combinators that we will be looking at here.Descendant Selec… Read More
  • CSS Overflow Sometimes the content shown is too large to be visible in a single line or division of the website. So, to avoid loss of that information we can… Read More
  • position Property The position property specifies the type of positioning method used for an elementThere are five different position values:staticrelativefixedab… Read More
  • Display Property The display property specifies if/how an element is displayed.Every HTML element has a default display value depending on what type of element i… Read More
  • Z-index The z-index property specifies the stack order of an element.When elements are positioned, they can overlap other elements.An element can have a… Read More

0 Comments:

Post a Comment

Do leave your comments