CSS CSS Layout CSS Layout Techniques Float

FRANKIE Ochoa
FRANKIE Ochoa
2,759 Points

CSS Layout

can someone please tell me how to get the text on the page to go around the img

style.css
/* Complete the challenge by writing CSS below */
.img {
  float: right;
}
index.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Developer Diane's blog</title>
  <link rel="stylesheet" href="page.css">
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <header>
    Developer Diane’s Blog
  </header>
  <article>
    <section class="intro">
      <img src="developer-diane.jpg" alt="Developer Diane coding on her laptop.">
      <h1>The verdict is in. CSS Layout is great!</h1>
      <p class="clear">I’ve been working with CSS for a while now, and I have to say, it’s pretty awesome. I love being able to separate content from presentation, and to keep all my styles in an external stylesheet.</p>
      <p>I’ve had a pretty good grasp on the basics for a while now, but I needed to learn more about how to control layout with my CSS. Understanding CSS layout meant first exploring the parts of the CSS box model.</p>
    </section>
    <footer>©2020 Developer Diane.</footer>
</body>
</html>

1 Answer

Peter Vann
MOD
Peter Vann
Treehouse Moderator 35,350 Points

Hi Frankie!

Two issues:

1) Since img is a native HTML element, you don't need the dot (it's the class selector - in other words, .img would target an element with the class of "img" and #img would target an element with the id of "img").

2) To get the text to wrap to the right, you have to float the image to the left

This passes both challenges:

/* Complete the challenge by writing CSS below */
img {
  float: left;
}

.clear { /***  Paragraph (any element, really, though) with the "clear" class. ***/
  clear: both;
}

I hope that helps.

Stay safe and happy coding!

FRANKIE Ochoa
FRANKIE Ochoa
2,759 Points

thank you that helps a lot