0
Space before and after <p> element
Hello everybody! I have a question. I am a bit confused about the space before and after the <p> element. If I want to add a paragraph, I should write the <p> element. --> <p>This is a paragraph.</p> But is this notation also right? --> <p> This is a paragraph. </p> Are spaces before and after <p> elements allowed? Thank you! Greets Imane
2 Antworten
+ 5
They are allowed, but they will typically be truncated in the browser output (unless you override that default behavior).
0
Hi Imane , what you are confused about is called white space collapsing. A browser automatically corrects any extra space between words in between elements. That's why it won't display your normal line break using enter key unless you use the <br/> element
You can take the advantage to make your code easier to read and neat. .