HTML markup:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<div class="container">
<p>
Lorem ipsum, dolor sit amet consectetur adipisicing elit. Ad maxime accusantium neque id omnis, deleniti nisi, vitae eius quia reprehenderit reiciendis, blanditiis vero eligendi. Reprehenderit blanditiis a odio deleniti mollitia id accusamus! Libero ab corrupti quo rem magnam fuga sunt dolor, repellendus adipisci. Quis soluta, suscipit doloribus inventore distinctio a molestias quas autem qui dolore non est beatae tempora numquam aliquam dolorem ut consequuntur sapiente asperiores, cumque nostrum officia?
</p>
</div>
</body>
</html>
CSS:
* {
margin: 0px;
padding: 0px;
box-sizing: border-box;
}
div {
border: solid black 1px;
margin: 30px;
padding: 30px;
};
I have tried universal selector but did not find any help.
Please note that I did this in VS Code.
update: Now I am using the class selector and it works.
But still, the question occurs why I can’t use the div tag directly.
2
Answers
The extra lines you see are the combination of the borders and the margins overlapping each other. To fix this issue, you have two options:
Here you have two Options:
1: Remove the margin from div
2: Add
box-sizing: border-box;
Note: The
box-sizing: border-box;
property controls how the total width and height of an element are calculated.you can use :after, :before pseudo to add border.