is there any difference between p and paragraph without this element?

4

If I create for example a <div> and within the tags I place "the text of lorum" would be the same as placing a <p> within the <div> with the same text?

  

Lorem ipsum pain sit amet, consectetur adipiscing elit. Phasellus rhoncus id augue to ullamcorper. Sed eu purus non nulla ornare feugiat sit amet nec erat. Maecenas quis quam vel lectus dictum varius vitae egestas fair. Integer in fringilla tortor. Donec dictum scelerisque vestibulum. Interdum and malaise fames ac ante ipsum primis in faucibus. In cursus massa vel hendrerit bibendum. In hac habitasse platea dictumst.

    
asked by Patricio Martin 28.11.2017 в 02:10
source

3 answers

6

Depends on what for you means "that is the same". In short words it is not the same and let's see why:

The div is an element that serves as a container, in which you can group elements.

The p is a paragraph element that has a semantic and structural purpose, worth the redundancy, is to write paragraphs of text.

In general, browsers set default values to html elements, each browser applies its own (margin, padding, etc).

And going back to the question, if you place the text inside a "p" tag, it is not the same as placing it in a div tag, since it contains a margin, which visually will change its composition.

I'll give you an example and you can see how the section where a paragraph is used contains additional margins by default.

div{border:2px solid red;}
<div>
 <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus rhoncus id augue a ullamcorper. Sed eu purus non nulla ornare feugiat sit amet nec erat. Maecenas quis quam vel lectus dictum varius vitae egestas justo. Integer in fringilla tortor. Donec dictum scelerisque vestibulum. Interdum et malesuada fames ac ante ipsum primis in faucibus. In cursus massa vel hendrerit bibendum. In hac habitasse platea dictumst. <p/>
</div>

<div>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus rhoncus id augue a ullamcorper. Sed eu purus non nulla ornare feugiat sit amet nec erat. Maecenas quis quam vel lectus dictum varius vitae egestas justo. Integer in fringilla tortor. Donec dictum scelerisque vestibulum. Interdum et malesuada fames ac ante ipsum primis in faucibus. In cursus massa vel hendrerit bibendum. In hac habitasse platea dictumst.
</div>
    
answered by 28.11.2017 / 02:29
source
1

div - of "division" -division. Used to create sections or group

The p (paragraph) element is appropriate to distribute the text in paragraphs. contents.

I hope this helps you greetings

div {
background: rgb(72, 172, 150)
}
<div class="">
  <p>
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  </p>
</div>

  <div class="">
    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  </div>

As you can see there is no difference between them visually

    
answered by 28.11.2017 в 02:28
1

The grace of the paragraph is that it provides a natural spacing between one paragraph and another (as a text editor would do). If you put all the text inside a div, the line breaks will not be reflected unless you manually insert them with a <br>

element

Using p

<div>
  <p>
  El presente documento habla sobre la antigua grecia.
  </p>

  <p>
  Grecia era un país. Sigue siendo un país y probablemente seguirá siendo un país.
  </p>

  <p>
  Este ha sido mi ensayo sobre grecia
  </p>
</div>

Not using p

<div>
  El presente documento habla sobre la antigua grecia.

  Grecia era un país. Sigue siendo un país y probablemente seguirá siendo un país.

  Este ha sido mi ensayo sobre grecia
</div>

That's basically the difference.

Currently there are a thousand ways to diagram the same thing. You can do a div for each paragraph, or a list without bullets, as you prefer. But in the early days of the web, when the sites were practically word documents visible on the internet (text, tables, photos and everything would be ...) the layout was not as flexible as today.

    
answered by 28.11.2017 в 12:20