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

What is the significance of using <p></p> and </strong> in document.write?

I noticed that whenever I write anything in document.write for code challenges I don't use the <p> or </p> markers around my text but I'm not sure what the significance of doing this actually is? I'm sure I must have missed it in a video at some point!

Similarly, I don't understand what using </strong> does to a string in a similar situation.

Apologies for how 'nooby' this question may be. I just noticed that this was being being done in the videos and didn't want to get into any bad habits early on!

Many Thanks.

2 Answers

Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,863 Points

Hey Ian,

Using the <p> tags around your text is for the HTML formatting. In HTML, text should be wrapped in some tag (h1, h2, p, etc) to maintain flow and for ease of styling and readability. When you use a <p> tag (you could also use <h1> or others), it is just adding another paragraph (or heading) to the code.

the <strong> tag is similar to bold. Visually it is the same thing, but you use strong in code to emphasize the importance of something. On screen it will be bold, but in code you know it it meant to be important (strong).

I hope this helps and clears some things up. Keep Coding! :)

Thank you! That's very useful!! :)