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

karan karan
seal-mask
.a{fill-rule:evenodd;}techdegree
karan karan
Web Development Techdegree Student 3,904 Points

String with HTML tag

As we write "<h2>Hello</h2>" inside a string and try to print it on the console it prints exactly the same with the tags, but how come when we use the value it displays the string in bigger Text (<h2>) and just skips the <h2> Tag as we used here to show it on the Web Page

1 Answer

Steven Parker
Steven Parker
210,837 Points

The console doesn't interpret the text, it just shows it as it is.

But when you put it into an HTML page, the tags are interpreted by the browser as an instruction to display the text inside them in a larger font.