grenfunday
grenfunday

Reputation: 121

How center unordered list with bullets?

I'm new to web programming and I can't figure out, how to place not only text, but also the unordered list bullets in the center? Here is code:

 <div style="text-align:center;">
    <h2 style="margin-top:43px;" class="text-center">Important years of life and work:</h2>
    <ul >
      <li>cat nip</li>
      <li>laser pointers</li>
      <li>lasagna</li>
    </ul>
  </div>

And here is the pic, to show you what I mean: enter image description here

Upvotes: 0

Views: 4765

Answers (2)

Razia sultana
Razia sultana

Reputation: 2211

h2{
  text-align:center;
  margin-top:43px;
}
 ul {
    display: inline-block;
    text-align: left;
    padding: 0;
}
   <div style="text-align:center;">
    <h2>Important years of life and work:</h2>
    <ul >
      <li>cat nip</li>
      <li>laser pointers</li>
      <li>lasagna</li>
    </ul>
  </div>

Upvotes: 0

Prasath V
Prasath V

Reputation: 1356

Try this one

div{
  text-align:center;
}ul{
  display:inline-block;
  text-align:left;
}
<div style="text-align:center;">
    <h2 style="margin-top:43px;" class="text-center">Important years of life and work:</h2>
    <ul >
      <li>cat nip</li>
      <li>laser pointers</li>
      <li>lasagna</li>
    </ul>
  </div>

Upvotes: 2

Related Questions