Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Loops, Arrays and Objects Tracking Data Using Objects Accessing Object Properties

Amandeep Pasricha
Amandeep Pasricha
14,932 Points

Why do we write <p> element tags if we aren't writing actual HTML?

Hi, I know this sounds stupid, I just don't get why we have to write HTML element tags in our javascript? He talked about this in the video but I didn't get his explanation.

1 Answer

Steven Parker
Steven Parker
210,475 Points

Inside the quotes, you are writing HTML, which the script then delivers to the page as content within the existing div element with an ID of "output". Then, the browser renders the HTML just as if it had been in the "index.html" file to start with.

In later courses, you'll learn ways to directly create elements in code and then attach them to the document, and with a much greater level of control.