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 JavaScript Basics Working with Strings Display the Value of a String on a Page

Why does my Browser only seem to recognize two elements Body and Header but not Main

document.querySelector('main').innerHTML = xxx will not run in Browser but if I replace main with body it does place the xxx on the web page. When I look at the elements it seems like only Body and Header are available.

I have the same issue, and I am not using my own webpage.

1 Answer

Are you using your own webpage? If you are, you need to create a main element in your HTML for that to work. You can create one by typing <main></main> inside the <body> tag. Hope this helped!