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


Matthew Schad
Matthew Schad
9,381 Points

Clearing Floated Elements. There must be something I'm not understanding

<!DOCTYPE html>
      <meta charset="utf-8">
      <title>Matthew Schad | HTML and CSS Portfolio</title>
      <link rel="stylesheet" href="CSS/styles.css">
      <link rel="stylesheet" href="CSS/normalize.css">
         <a href="index.html"><h1>Matthew Schad</h1>
         <h2>Front End Web Developer</h2></a>
         <a href="work.html">Projects</a>
         <a href="index.html">About</a>
         <a href="contact.html">Contact</a>
     <div class="container">
        <div class="primary col">
          <div class="headshot">
            <img src="img/headshot" alt"from cape coral, florida" title"front end web developer">
           <p>I'm Matthew Schad, a web developer focused on expanding my knowledge in ways I can improve the user experience of webpages.</p>
        <div class="secondary col">
          <p>My skills and qualifications include:</p>
            <li>Proficient in Windows and Mac Operating Systems.</li>
            <li>Knowledged in utilizing Adobe software, such as Photoshop, Illustrator, and InDesign.</li> 
            <li>Experience with Squarespace.</li>
            <li>Basic knowledge in SEO, such as utilizing alt tags, titles, and avoiding keyword saturation and rather aiming for good                   keyword phrases that are relevant to the content.</li> 
            <li>I have a good eye for composition, developed through photography, graphic design, and other forms of art.</li>
            <li>I genuinely enjoy assessing circumstances and solving problems.</li>
            <li>I'm an avid learner, ready for a career of learning and utilizing new innovations.</li> 


header {
  position:absolute 120px;
  padding: 5px;  

a h1 {

a h2 {

h1, h2, nav a {

nav {

nav a {
  display: inline-block;
  padding: 0 15px;

a {

img {

.container {
  box-sizing: border-box;

.col {
  float: right;
  padding: 1em;

.primary {
  width: 50%;

.secondary {
  width: 40%;

.clearfix::after {
  content: "";
  display: table;
  clear: both;

.headshot {
  display: inline-block;

I can't get the headshot floated to the right side of the page, I've tried numerous ways of clearing the elements around it and collapsing the container space around the image, but no luck. What am I doing wrong?

2 Answers

Just a guess since I have not inspected the above code live in a browser with a debug tool.

Maybe try replacing the .headshot rule with the following instead.

.headshot img {
  float: right;
  margin: 0 0 1.5em 1.5em; /* breathing space on the bottom and left */

P.S. - It looks like the alt and title tags are missing equal signs for the img tag in your original post. I'm thinking that may just be a copy and paste issue but still, couldn't hurt to double check.