+ 2

<p> or <div>?

What is the difference between <p> and <div>? I see both being used, but they seem to have the same purpose (sort, very new to web dev). Thanks!

28th Oct 2020, 8:58 PM
Barbara
Barbara - avatar
5 Réponses
28th Oct 2020, 11:09 PM
Mohammed Qadir khan
+ 1
kosi okorie p tags are block as well but otherwise, yes.
28th Oct 2020, 11:27 PM
Maxwell Anderson
Maxwell Anderson - avatar
0
<div> is a block element used to divide the page into sections while <p> is an inline element used for dividing into paragraphs
28th Oct 2020, 9:14 PM
kosi okorie
kosi okorie - avatar
0
In truth <p> is block too. On MY opinion, you can add tags that make your code clear. Tag are to MARKUP (HyperText Markut Language, html, remember?). So you use tags for ir, to say l <num ber>5</number> My sum is <sum>15</sum> And you CAN do it, even these tags doesn't exist, and the tag will not show on browser. So, why use tags? Tags are important when using CSS, to what I wanna bigger, what go inside a box, change color. And when animating and other commands with JavaScript. <p> is a paragraf tag, it is defaut block leve (mean that come with line break), but you can change if want it. <div> is most used, it's like a container. When grouping infos you take it inside a div (and add class name, then you can style with css). Obs: you can write HTML using only div, intead use: <div class="header> content </div> <div class="paragraphs> content </div> So on... But then you need go CSS and style it, all tags is like it, premade div.
28th Oct 2020, 10:44 PM
Marcelo Anjos
Marcelo Anjos - avatar
0
<div class="page1"> <p> I'm going to write a story </p> <p> Once upon a time</p> </div> <div class="author"> </div class="about"> <p>My name is Barbara</p> <p>I'm reading html</p> </div> <div class="social"> Follow me in: <p>Facebook.com</p> <p>Twitter</p> </div> </div> Obs: I put div inside div because Cascaring. So div help clear what is what (group things). Obs2: you don't need get a lot of tags inside html, but as I said, it help get clean. And when you learn CSS you will use to style thing by group (for example all important word red, then <strong>something important</strong> Css: strong {color:red;} Obs: this way ALL <strong> will be red, that why we use "class", to specify.
28th Oct 2020, 10:54 PM
Marcelo Anjos
Marcelo Anjos - avatar