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 Font CSS FontFont properties are used to add different styles to the fonts.Font properties are used to change the style, size, weight, etc. of the fo… Read More
  • CSS Linkslinks can be styled in many different waysStyling LinksThe four links states are:a:link - a normal, unvisited linka:visited - a link the user has visi… 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
  • CSS LIST There are two main types of listsunordered lists (<ul>) - the list items are marked with bulletsordered lists (<ol>) - the list item… 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

0 Comments:

Post a Comment

Do leave your comments