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

Jakub Jeczalik
Jakub Jeczalik
5,379 Points

How to align text horizontally next to images.

How do I position the h1 and p tags on the left of the three images? Thanks

HTML:

  <ul class="classic">
    <h1>All Time Classic</h1>
    <p>
      This is just some sample text<br>
      which you can edit
    </p>
    <li class="kiwi">
      <img src="C:\Users\Jakub\Desktop\Practise Websites\pictures\kiwi.jpg" alt="picture of kiwi cupcake" class="pictures1">
      <h3>Kiwi</h3>
    </li>

    <li class="mango">
      <img src="C:\Users\Jakub\Desktop\Practise Websites\pictures\mango.jpg" alt="picture of a mango cupcake" class="pictures1">
      <h3>Mango</h3>
    </li>

    <li class="cantaloupe">
      <img src="C:\Users\Jakub\Desktop\Practise Websites\pictures\cantaloupe.jpg" alt="picture of a cantaloupe cupcake" class="pictures1">
      <h3>Cantaloupe</h3>
    </li>
  </ul>

CSS:

.classic {
  text-align: left;
  text-decoration: none;
  display: inline-block;
  width: 100%;

}

.kiwi,
.mango,
.cantaloupe {
  width: 25%;
  float: left;
  display: inline-block;
  text-align: center;

}

1 Answer

Óscar Hernández sandoval
Óscar Hernández sandoval
9,257 Points

using flex-box you can align this h1 tag, is more responsive. use a container for this 3 classes see the link of this example https://css-tricks.com/snippets/css/a-guide-to-flexbox/

.·div { display: flex; justify-content: flex-start;

}