CSS CSS Layout CSS Layout Techniques Float

enrico bonadiman
enrico bonadiman
Front End Web Development Techdegree Student 2,629 Points

wrapping text around an image on css

why is my code not accepted by the challenge ? I need to wrap the text around the image on the right side.

/* Complete the challenge by writing CSS below */
.main-image {
float: left;
width: 400px;
margin: 0 1rem 1rem 0;
<!DOCTYPE html>
<html lang="en">
  <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">
    Developer Diane’s Blog
    <section class="intro">
      <img class="main-image" 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>
    <footer>©2020 Developer Diane.</footer>

1 Answer

Peter Vann
Peter Vann
Treehouse Moderator 31,785 Points

I think, in this challenge, they want you to only code the CSS, not altering the HTML at all.

This passes (code in style.css):

/* Complete the challenge by writing CSS below */
.intro img {
  float: left;
  width: 400px;
  margin: 0 1rem 1rem 0;

Thus demonstrating that you understand descendant selector syntax (img being the descendant of the section with the 'intro' class). Keep in mind, 'descendant' just means an element nested within another (considered the 'parent') element.

I hope that helps! Happy coding!