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

Helen Astill Steynor
Helen Astill Steynor
3,848 Points

Where is using HTML tags in a Javascript file introduced?

I'm doing the Practise Javascript Maths Methods video and Dave is again talking about using HTML tags in Javascript and I'm wondering if I've somehow missed a video introducing how to use HTML tags in Javascript. Does anyone know which video this is included in please? I've looked back over all the videos I've done so far in the Javascript Basics course and can't find anything anywhere.

Also, in this challenge he's mentioning using a linebreak tag - <br> - but again this has never been introduced to me in either the Javascript Basics, How to Make a Website or CSS Basics courses (I'm on the Front End Web Development track). I'm a complete novice when it comes to programming/scripting and felt like I was keeping up pretty well with everything so far, but I'm finding that the Javascript Basics course seems to be missing things out that should be included on a 'Basics course'.

Thank you in advance for any help/advice.

2 Answers

MIlton Tulli
MIlton Tulli
15,884 Points

Hi Helen!,

Good luck!

andren
andren
28,558 Points

During the "Practise Javascript Maths Methods" you are just meant to use HTML tags within strings, and then write those strings to the page using document.write. You can't use HTML tags within JavaScript outside of strings, with the exception of JSX but that's a more complex topic which is not relevant to this challenge.

The document.write method was demonstrated during the first couple of video of the Basic JavaScript course, and HTML tags were used during those demonstrations.

As for the <br> tag I'm somewhat surprised that was not shown off during the "How to Make a Website" course as it is a pretty basic HTML tag. But there are a lot of HTML tags so running into one you are unfamiliar with is not something that is going to be a rarity when doing web development. And usually a short Google search will bring up a pretty good explanation of what the tag does. The <br> tag for example simply creates an empty line, which is useful for spacing content.