aade00fd-625c-48ff-8e0b-5593fe6f1f6d
prompter
How do I center a div in a webpage using CSS?
206b24b0-f72e-424b-805d-2d122b461a22
aade00fd-625c-48ff-8e0b-5593fe6f1f6d
assistant
To center a div in a webpage using CSS, you can use the following CSS code:

div {
  width: 50%; /* Set a fixed width for the div */
  margin: 0 auto; /* Center the div horizontally */
}

The width property sets the width of the div, while the margin property with values 0 auto centers the div horizontally. The 0 value sets the top and bottom margins to zero, while the auto value centers the div horizontally.
5b39355e-377b-48a1-a4aa-a384c41fe15f
206b24b0-f72e-424b-805d-2d122b461a22
prompter
This div is only centered horizontally. How can I center it vertically as well?