Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

what is the difference between <p> and text nodes?

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

There are a few reasons not to use "naked" content in your markup:

  1. 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).
  2. When you don’t wrap your content in markup, you have no meaningful way to target and style it with CSS
  3. When you don’t wrap your content in markup, you have no easy way to access it with JavaScript for manipulation

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!

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading