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 trialOğulcan Girginc
24,848 PointsWhy not using '<p>' and '</p>' results same as using both?
Both
person.name = 'Rainbow Dash';
message += 'But, I wish my name was ' + person.name + '.';
and
person.name = 'Rainbow Dash';
message += '<p>But, I wish my name was ' + person.name + '.</p>';
results in same outcome: But, I wish my name was Rainbow Dash. Wasn't I suppose to get an error, when paragraph tags are not included?
1 Answer
Nejc Vukovic
Full Stack JavaScript Techdegree Graduate 51,574 PointsHi.
No if you look at that this way then that's no error. There is no syntax error or any other error present in the code.
You can use either. But if you don't use the paragraph tags then the text will be a text without styling rules for a paragraph.
To see the difference make a new Workspace and write a basic HTML backbone and input your coding and make sure you have some text before the js code and some after.
The difference is that when using the tag you get the style for the tag applied to the HTML ( the browser defaults ) and if you don't use the tags nothing is applied but still renders in your browser.
Oğulcan Girginc
24,848 PointsOğulcan Girginc
24,848 PointsThat's what I thought, but wasn't sure. Thanks a lot Nejc! :)