Center align the <div> element using margins. - HTML CSS CSS

HTML CSS examples for CSS:Quiz

Description

Center align the <div> element using margins.

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
div {<!--from w  w  w  . j  a v  a 2 s .c o  m-->
    margin-left: auto;
    margin-right: auto;
    width: 300px;
    background-color: #EEEEEE;
}
</style>
</head>
<body>

<div>
  <p>This is a test. This is a test. This is a test.</p>
  <p>This is a test. This is a test. This is a test.</p>
</div>

</body>
</html>

Related Tutorials