chibiw3n
chibiw3n

Reputation: 367

How do I change the left and right padding of a div?

I am new to css and can't figure out how to remove left and right paddings of the website heading in gray with "Website" in the center. In other words, I am trying to reduce the amount of gray area on the left and right side of the heading text. I tried to reduce the padding to 0px but it didn't do anything.

enter image description here

Upvotes: 0

Views: 68

Answers (1)

Toxnyc
Toxnyc

Reputation: 1350

That's because the Website element is a block, it's 100% width by default. We can reduce the width of your choice and margin:auto to set it to the center.

.container {
  width: 100vw;
  height: 100vh;
}

h1 {
  background-color: gray;
  text-align: center;
  color: white;
  
  /**/
  width: 200px;
  margin: auto;
}
<div class="container">
  <h1>Website</li>
</div>

Upvotes: 1

Related Questions