Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Sandeep Singh
3,582 PointsHi , image gallery is not in center of the page.
Hi , i am facing this problem every time with my coding . The problem is - alignment of header and footer's text or image always in center of the page with property text-align .But , alignment of image gallery is not in the center of the page.Its slight left or right side depend on the size of the page. If i use wrapper to warp all code with text align property then the same problem what is wrong with this coding below -
<!DOCTYPE html>
<html>
<head>
<title>---------</title>
<link rel="stylesheet" href="main.css">
</head>
<body>
<nav>
<ul id="mainMenu">
<li><a href="#">------------</a></li>
<li><a href="#">------------</a></li>
<li><a href="#">------------</a></li>
<li><a href="#">------------</a></li>
<li><a href="#">------------</a></li>
</ul>
</nav>
<header>
<h2 id="mainHeading">------------</h2>
<!-- <h2 id="wild"><a href="#">------------</a></h2> -->
</header>
<ul id="gallery">
<li><img src="img/------------.jpg"></li>
<li><img src="img/T------------.jpg"></li>
<li><img src="img/------------.jpg"></li>
<li><img src="img/------------.jpg"></li>
</ul>
<footer>
<a href="https://------------ " target="_blank"><img src="img/facebook-wrap.png" class="icon"></a>
<a href="https://------------ " target="_blank"><img src="img/twitter-wrap.png" class="icon"></a>
<P>------------ . </P>
</footer>
</body>
</html> ```html
here ..css file -
```css
* {
box-sizing: border-box;
}
body{
margin: 0;
}
img{
max-width: 100%;
}
a{
text-decoration: none;
color: #696969;
}
nav ul{
list-style: none;
text-align: center;
padding-left:0.10em;
}#mainMenu li{
padding: 5px;
}
header{
background-image: url("img/sys.jpg");
background-repeat: no-repeat;
background-position: center;
background-size: cover;
text-align: center;
margin: 0 0 15px 0;
/*width: 100%;*/
height: 500px;
}#mainHeading{
font-size: 32px;
/*text-align: center;*/
color: #fff;
border-bottom: 1px solid;
padding: 0 0 5px;
margin: 140px 0 0 0;
display: inline-block;
}#gallery{
list-style: none;
}#gallery li{
width: 45%;
float: left;
margin: 2.5px;
}
footer{
text-align: center;
clear: both;
}
.icon{
padding: 5px;
width: 45px;
height: 45px;
}```
2 Answers

Cosmin Ionut Mindru
2,110 PointsAdd the property "margin: auto" to your "nav ul" selector.

Sandeep Singh
3,582 PointsHow to make it in center of the page?
Matthew Lang
13,471 PointsMatthew Lang
13,471 PointsYour #gallery is floated left. This takes your gallery out of the usual layout of the page and glues it to the left side.