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

Side by side elements.

How do get two elements to display side by side. I can't seem to get the two boxes to not display diagonally. Please tell me what I'm doing wrong.

HTML

<!DOCTYPE html>
<html lang="en">
<head>  <meta charset="utf-8" />    
    <title>title</title>
</head>
<body>
  <article>
   <div id="content"></div>
   <aside>
   </aside>
  </article>
</body>
</html>
CSS

article {
    width: 400px;
    height: 400px;
    background: orange;
    margin: 0;
    position:absolute;
}
div#content {
    width:150px;
    height:150px;
    background:yellow;
    margin-top:100px;
    position:relative;
}
aside {
    width: 150px;
    height: 150px;
    background: blue;
    margin: 0;
    float: right;
}

1 Answer

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

When selecting an 'id,' you use just #id_name.

Try removing "div" from your second declaration in CSS to read just "#content"

That should work.

Jason