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

JavaScript

Dontre Waggoner
Dontre Waggoner
9,748 Points

why are my divs displaying diagonally, I followed exactly as you did in the video. is it the css?

My code works, but my divs display diagonally. I used workspace and a personal text editor of my choice but I'm still seeing the same result. Is it the CSS that is broken?

Hey Dontre.

If you're able to post the source code of your web page I'd be happy to take a look.

Dontre Waggoner
Dontre Waggoner
9,748 Points

Hi Terran,

Thanks for the fast reply. I didn't touch the CSS but here's what my Javascript looks like:

var html = '';

for (var i = 1; i <=10; i +=1){ html += '<div>' + i + '<div>'; } document.write(html);

Dontre Waggoner
Dontre Waggoner
9,748 Points

I'll give it a try, thanks for your help!

1 Answer

Your divs are diagonal because your closing div tag is missing a slash in your Javascript.

This

html += '<div>' + i + '<div>'; 

should be

html += '<div>' + i + '</div>'; 
Dontre Waggoner
Dontre Waggoner
9,748 Points

It works!! I'm a little embarrassed that's what it was haha. Thank you so much! =)