Jump to content
  • 0

Кто сможет объяснить отличие <div> от <p>


FishNetWeaver
 Share

Question

<!doctype html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>HTML CSS Example</title>

<style>

body {

width: 50%;

margin: 8px auto;

font: 1em/100% sans-serif;

color: #000;

}

.ex_01 {

line-height: 250%;

background-color: #ccc;

padding: 20px;

text-shadow: 0 1px 0 #fff;

}

.in_01 {

background-color: #999;

padding: 20px;

text-shadow: 0 1px 0 #ccc;

}

.in_02 {

background-color: #666;

padding: 20px;

text-shadow: 0 1px 0 #999;

}

</style>

</head>

<body>

<!--

1. div.ex_01>lorem20+div.in_$$*2>lorem20

2. p.ex_01>lorem20+p.in_$$*2>lorem20

-->

<div class="ex_01">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Assumenda, sed doloremque libero voluptas asperiores animi consequatur ducimus nam cupiditate placeat.

<div class="in_01">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Ipsum at eligendi ab maxime culpa natus voluptatibus cumque praesentium a quis.</div>

<div class="in_02">Quo, fuga, similique, a ad at eum nam ullam blanditiis unde reprehenderit expedita aliquam incidunt odit quaerat accusantium distinctio libero.</div>

</div>

<p class="ex_01">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Consequuntur laudantium voluptatibus eaque fugit necessitatibus numquam sequi exercitationem quis error dolore?

<p class="in_01">Lorem ipsum dolor sit amet, consectetur adipisicing elit. Nam, reiciendis saepe ipsam. Adipisci ullam illo dolore nulla atque veniam deleniti!</p>

<p class="in_02">Neque, totam, unde, ratione commodi minima quis accusantium esse eligendi magnam illum tempore perferendis quam fugit dolor blanditiis similique quo.</p>

</p>

</body>

</html>

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Спецификация. Или на htmlbook'e прочитай.

 

 

 Элемент <div> предназначен для выделения фрагмента документа с целью изменения вида содержимого.

 

Элемент <p> определяет текстовый абзац.

Link to comment
Share on other sites

  • 0

Спецификация и DOM-инспектор в браузере.

У P может быть только текстовое или «текстоподобное» (phrasing) содержимое, а закрывающий тег для него необязателен. Поэтому перед любым «блочным» элементом, включая другой P, он неявно закрывается автоматически. Это стандартное поведение.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy