Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

My images are not horizontaly aligned

I am writing step by step with Lesson "How to make Web Site", but i use for the Gallery photos i've made. On second row one is collapsed with around 2 cm, on the 4th row - whole length and move to the right. If you see the problem, please tell me. Thank you very much.

https://w.trhou.se/a2bb8rup49

2 Answers

Indigo Timber
Indigo Timber
5,388 Points

Hello, Veselina!

I found an extra <li> element in your html markup which was causing issues. I also added a css property called clear: both to one image which was still not aligned. This solution might be a bit outside the scope of that lesson. Anyway, this seems to make the images align horizontally:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Felix40</title>
    <link rel="stylesheet" href="css/normalize.css">
     <link href='https://fonts.googleapis.com/css?family=Covered+By+Your+Grace' rel='stylesheet' type='text/css'>
    <link href='http://fonts.googleapis.com/css?family=Nunito:400,300' rel='stylesheet' type='text/css'>
    <link rel="stylesheet" href="css/main2.css">
  </head>
  <body>

   <header>
     <a href="index.html" id="logo">
     <h1>Felix</h1>
       <h2>The German Spitz</h2>
     </a>

     <nav>
       <ul>
         <li><a href="index.html" class="selected">Daily Routine</a></li>
         <li><a href="about.html">About</a></li>
         <li><a href="tips.html">Tips</a></li>
       </ul>
     </nav>
     </header>
    <div id="wrapper">
      <section>
        <ul id="gallery">
          <li>
          <a href="img/FelixUpper.jpg">
            <img src="img/FelixUpper.jpg" alt="Hello World">
            <p>In the Upper garden for a first time</p></a>
          </li>
          <li>
          <a href="img/FelixHi.jpg">
            <img src="img/FelixHi.jpg" alt="Hello">
            <p>Hello, my name is Felix</p></a>
          </li>
          <li style="clear: both;">
          <a href="img/Felix.jpg">
            <img src="img/Felix.jpg" alt="Hello World">
            <p>Hello World</p></a>
          </li>
          <li><img src="img/FelixLeft1.jpg" alt="">
            <p>Dog to the left</p>
          </li>
          <li>
            <a href="img/Felix16.jpg">
            <img src="img/Felix16.jpg" alt="">
            <p>The Invisible</p></a>
          </li>
          <li>
            <a href="img/Felix17.jpg">
            <img src="img/Felix17.jpg" alt="">
            <p>Stay calm, Lady</p></a>
          </li>
          <li>
            <a href="img/Felix61.jpg">
            <img src="img/Felix61.jpg" alt="">
            <p>Starting a wide yawn</p></a>
          </li>
          <li>
            <a href="img/Felix12.jpg">
           <img src="img/Felix12.jpg" alt="">
            <p>Interesring dogs i met here</p></a>
           </li>
         </ul>
      </section>
      <footer>
        <a href="http://facebook.com/Felix40"><img src="img/facebook-wrap.png" alt="for congrats and presents" class="social"></a>
        <a href="http://twitter.com/myOwnerVF"><img src="img/twitter-wrap.png" alt="for complaints" class="social">
        </a>
        <p>&copy;  2016 Felix</p>
      </footer>
     </div>
  </body>
</html>

Thanks a lot, Daniel, Now all is correct! Regards