Dan R. answered 04/03/19
HTML Expert
To horizontally align a fixed-width div to the center of the screen, set its margin to "margin:0 auto;". Try this as an example:
#yourdiv {
width:800px;
margin:0 auto;
background-color:green;
height:200px;
}
Dan R. answered 04/03/19
HTML Expert
To horizontally align a fixed-width div to the center of the screen, set its margin to "margin:0 auto;". Try this as an example:
#yourdiv {
width:800px;
margin:0 auto;
background-color:green;
height:200px;
}
Kristy V. answered 04/03/19
University Instructor in CS/IT Specializing in Web Design
To horizontally center a div with a width of 800px on a webpage, you can add the following CSS code to your stylesheet:
div { width: 800px; margin: auto; }
I hope this answers your question.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.