i’m learning HTML, and it is not clear yet to me what is the difference in using a text node or a <p> element.
more precisely, what are the advantages and disavantages of using a <p> element? what about text nodes?
There are a few reasons not to use "naked" content in your markup:
- The primary purpose of HTML is to semantically wrap the content it contains– paragraph content should be wrapped in a
<p>, address information should be wrapped in
<address>, etc. When you do this, it is a clue to various technologies that read HTML as to how the information it is reading should be interpreted. Such technologies include search engines (to understand what is on your page) and screen readers (to read content in a manner that makes sense to users who might not be able to see the screen).
- When you don’t wrap your content in markup, you have no meaningful way to target and style it with CSS
Basically, the whole intent of HTML is to semantically wrap content, and doing so also enables other functionality in the browser. There’s really no reason not to do so– so, wrap your content appropriately!