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

karan Badhwar
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
karan Badhwar
Web Development Techdegree Graduate 18,135 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
229,732 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.