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.
Swedina Yolanda931 Points
Can I just write document.write('<p>Sorry, the number was</p> ' + randomNumber); ?
Is it really necessary to put the closing tag in the end, since there is no string after the var randomNumber?
Jennifer NordellTreehouse Teacher
Hi there! It depends entirely on how you want it to look on the page. In the example, the closing
<p> tag was included after the random number so that the random number will appear as a part of the "block". Most browsers implement the paragraph with a default of
display: block;. This includes a small margin above and below it. Also, had you styled your paragraphs, the random number would not inherit those styles, but rather the styles applied to the body. Ultimately, your way would work too, but it depends entirely on how you want it to look.