-1

These two simplified HTML5 codes gets the same result:

code #1:

<html>
<head>
    <title>test</title>
</head>
<body>
    <p>test1</p>
</body>
</html>

--

code #2:

<html>
<head>
    <title>test</title>
</head>
<body>
    test1
</body>
</html>

====

The output is the same in both cases, the screen prints the word "test1", so what the use of the tag <p> ? how does the browser understand the two codes? please note that the file code is .html extension

Asons
  • 84,923
  • 12
  • 110
  • 165
  • 2
    Take a look at this: http://stackoverflow.com/questions/28529390/ok-to-have-text-in-div-without-paragraph-tag – blackandorangecat Apr 02 '17 at 22:13
  • Possible duplicate of [OK to have text in div without paragraph tag?](http://stackoverflow.com/questions/28529390/ok-to-have-text-in-div-without-paragraph-tag) – Matt Goodrich Apr 03 '17 at 02:26

1 Answers1

1

The <p> tag stands for paragraph, which is used for text, and you can read more about it at MDN: https://developer.mozilla.org/en/docs/Web/HTML/Element/p

If you take a a good look you'll see the output is not the same, the p is slightly far down the page because it has a default margin set, which for example a div does not.

The browser parse through the code/markup and render the content in each tag accordingly to that particular tags default layout settings.

Asons
  • 84,923
  • 12
  • 110
  • 165