< p为H.和< div>和休息 [英] <p> and <div> and breaks

查看:42
本文介绍了< p为H.和< div>和休息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

1。这是来自W3C推荐页面的一些html。


< P> aaaaaaaaa< DIV> bbbbbbbbb< / DIV>< DIV> cccccccc< P> dddddddd< / DIV>


2.虽然我认为它不会产生任何影响,但我还是尝试了包含< / p>的


< P> aaaaaaaa< / p>< DIV> bbbbbbbbb< / DIV>< DIV> cccccccc< P> dddddddd< / p>< / DIV>

FF2将#1和#2都表示为:

------------------

aaaaaaaaa / br / >

bbbbbbbbb

cccccccc


dddddddd


所以它看起来像FF2没什么在< div>中允许< por< p> s

内的< div>还有其他解释吗? FF是< pterminates之后的双重休息时间(< br>< br>>)< pand另一次单独休息之后的单个

休息时间在以下之前

< div>。第二个< divbe在点击< p>时会终止吗?它看起来像是



W3C说大多数浏览器会将第一个浏览器显示为:

----- -----------------

aaaaaaaaa

bbbbbbbbb

cccccccc


dddddddd


.... IE7如何显示它。

IE7将#2呈现为:

-----------

aaaaaaaaa

bbbbbbbbb

cccccccc


dddddddd

看起来在IE7中,< pCAN包含一个< divwhich,当我们添加#1和#2时,它们占据了
的差异< / p> s。 < pin#1

可能不会结束,直到它击中第二个< p> ;.


我对这些结果感到惊讶。


问候,

Kent Feiler
www.KentFeiler.com

解决方案

Scripsit Kent Feiler:


2.虽然我认为它不会产生任何影响,但我还是尝试了包含< / p>的



根据HTML规范,< / ptag在经典

(基于SGML)HTML中始终可以省略,并且始终需要(对于XHTML中的< pelement)。当

可以省略时,遗漏不应该对意义或渲染产生任何影响。


但那不是浏览器(又称wowsers或tag slurpers)表现。只需

就可以了。如果您使用经典,请使用< / peven HTML(你应该这样做,除非你知道你从XHTML得到的一些实际好处),因为这样,

浏览器行为更容易预测。
< blockquote class =post_quotes>
FF2将#1和#2都表示为:



那么什么?


所以看起来FF2在< div>中< por< p> s

内不允许< div> s ???



什么?什么意思不允许什么?它是HTML

规范,不允许< divwithin< p> ;.


FF是

在< pterminates或< br>< br>之后< pand< pand< pand>之后的另一次单独休息之后< br>< br>>

< div>。第二个< divbe在点击< p>时会终止吗?它好像是b $ b。



停止猜测。查找关于HTML的教程并阅读有关标签和元素的内容。

如果问题仍然存在,请回来。


W3C表示大多数浏览器都会显示第一个:



什么?哪里?我们是否应该猜测你读哪个文件的哪一部分?


一般来说,W3C文件对浏览器的评价部分过时了,部分是

刚刚制作 - (也许是一厢情愿的想法),并且部分正确。


-

Jukka K. Korpela(Yucca)
http://www.cs.tut.fi/~jkorpela/


Kent Feiler写道:


1.这里是来自W3C推荐页面的一些html 。



大概是 http://www.w3.org/TR/html4/struct/global.html#h-7.5.4

但是哦,也许不。它不完全相同。你是在哪里找到那个东西的。


>

< P> aaaaaaaaa< DIV> bbbbbbbbbb< / DIV>< DIV> cccccccc< P> dddddddd< / DIV>


2.虽然我认为它不会产生任何影响,但我尝试了它包含< / p>的
好吧。


< P> aaaaaaaa< / p>< DIV> bbbbbbbbb< / DIV>< DIV> cccccccc< P> dddddddd< / p>< / DIV>


FF2将#1和#2都表示为:

------------------

aaaaaaaaa

bbbbbbbbb

cccccccc


dddddddd


所以看起来FF2在< div>中< por< p> s

内不允许< div> s ???还有其他解释吗? FF是< pterminates之后的双重休息时间(< br>< br>>)< pand另一次单独休息之后的单个

休息时间在以下之前

< div>。



肯特,


忘掉休息时间。忘了< br>。他们只会让你感到困惑。


只要你想让段落

打破下一个段落,就可以在段落中单独添加一个< br>线。否则,永远不会。忘记它们,以及

它们之间的间距。


您所看到的,或者至少在看,是< p> ;

元素会自动终止。当浏览器通过aaa'读取
时,准备渲染< p>,它会碰到< div>

并意识到它应该终止段落并开始一个新的块

项目,div。


阅读< http://www.w3.org/TR/html4/intro /sgmltut.html#h-3.2.1> ;.


现在,*它发生*个别浏览器在某些特定浏览器之前和之后具有某些默认的垂直

间距元素,包括< pand< div>,和

*它们发生在几个浏览器中似乎很常见,

它也可能*看起来像*虽然间距相当于插入< brinto源的

结果,但是忘了这一切。只需

标记内容,并为你想要的间距设置元素的样式。


第二个< divbe可以在点击< p>?时终止它好像是b $ b看起来像。



我认为div没有终止,但是段落正在开始。您的

浏览器可能在< p>之前有一个默认的垂直间距。在那里。


>

看起来在IE7中< pCAN包含< div>



我不这么认为。 < divis块级标记。但< pcannot包含

块级元素:
http://www.w3.org/TR/html4/struct/text.html#edef-P


我不知道为什么IE6和IE7不同,确切地说,但不同

浏览器是不同的。你是怪异模式吗?或者是什么?


HTH

-

John


在12/19/2006 02:09 PM,Kent Feiler写道:


1.这里是来自W3C推荐页面的一些HTML。


< P> aaaaaaaaa< DIV> bbbbbbbbb< / DIV>< DIV> cccccccc< P> dddddddd< / DIV>


2.虽然我没有我认为这会有所不同,我尝试了它/ b $ b,其中包含了< / p> ;.


< P> aaaaaaaaa< ; / p>< DIV> bbbbbbbbb< / DIV>< DIV> cccccccc< P> dddddddd< / p>< / DIV>


FF2同时呈现#1和# 2如:

------------------

aaaaaaaaa


bbbbbbbbb

cccccccc

ddddddd


所以看起来FF2不允许< div>在< div>中< p> s
内的< div> ???还有其他解释吗? FF是< pterminates之后的双重休息时间(< br>< br>>)< pand另一次单独休息之后的单个

休息时间在以下之前

< div>。第二个< divbe在点击< p>时会终止吗?它看起来像是



W3C说大多数浏览器会将第一个浏览器显示为:

----- -----------------

aaaaaaaaa

bbbbbbbbb

cccccccc


dddddddd


....这是IE7如何显示它。


IE7将#2呈现为:

-----------

aaaaaaaaa

bbbbbbbbb

cccccccc


dddddddd


看起来在IE7中< pCAN包含一个< divwhich可以解释

之间的差异当我们添加< / p>时,#1和#2。 < pin#1

可能不会结束,直到它击中第二个< p> ;.


我对这些结果感到惊讶。


问候,


Kent Feiler
www.KentFeiler.com



一个<元素只能包含内联元素和文本:
http://www.w3.org/TR/html4/ struct / text.html#h-9.3.1


我可能倾向于说FF是对的,但我不确定。

-
pa ****** *************@earthlink.net
http://home.earthlink.net/~mumia.w.18.spam/


1. Here''s some html from a W3C recommendations page.

<P>aaaaaaaaa<DIV>bbbbbbbbb</DIV><DIV>cccccccc<P>dddddddd</DIV>

2.Although I didn''t think it would make any difference, I tried it
with the </p>s included as well.
<P>aaaaaaaaa</p><DIV>bbbbbbbbb</DIV><DIV>cccccccc<P>dddddddd</p></DIV>
FF2 renders both #1 and #2 as:
------------------
aaaaaaaaa

bbbbbbbbb
cccccccc

dddddddd

So it looks like FF2 doesn''t allow either <div>s within a <por <p>s
within a <div>??? Is there some other explanation? FF is either
putting a double break (<br><br>) after the <pterminates or a single
break after the <pand another single break before the following
<div>. Could the second <divbe terminating when it hits the <p>? It
looks like it.

W3C says that most browsers will show the first one as:
----------------------
aaaaaaaaa
bbbbbbbbb
cccccccc

dddddddd

....which is how IE7 shows it.
IE7 renders #2 as:
-----------
aaaaaaaaa

bbbbbbbbb
cccccccc

dddddddd
It looks like in IE7 a <pCAN contain a <divwhich accounts for the
difference between #1 and #2 when we add the </p>s. The <pin #1
probably doesn''t end until it hits the second <p>.

I was surprised by these results.

Regards,
Kent Feiler
www.KentFeiler.com

解决方案

Scripsit Kent Feiler:

2.Although I didn''t think it would make any difference, I tried it
with the </p>s included as well.

By HTML specifications, the </ptag is always omissible in "classic"
(SGML-based) HTML and always required (for a <pelement) in XHTML. When
omissible, the omission should not have any effect on meaning or rendering.

But that''s not how browsers (a.k.a. wowsers or tag slurpers) behave. Just
live with it. Use </peven if you use "classic" HTML (as you should, unless
you _know_ some actual benefit that you get from XHTML), because that way,
browser behavior is more predictable.

FF2 renders both #1 and #2 as:

So what?

So it looks like FF2 doesn''t allow either <div>s within a <por <p>s
within a <div>???

What?? What do you mean by not allowing something? It''s the HTML
specifications that disallow <divwithin <p>.

FF is either
putting a double break (<br><br>) after the <pterminates or a single
break after the <pand another single break before the following
<div>. Could the second <divbe terminating when it hits the <p>? It
looks like it.

Stop guessing. Find a tutorial on HTML and read about tags and elements.
Then come back if problems remain.

W3C says that most browsers will show the first one as:

What? Where? Are we supposed to guess which part of which document you read?

Generally, what the W3C documents say about browsers is partly dated, partly
just made-up (wishful thinking perhaps), and partly correct.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


Kent Feiler wrote:

1. Here''s some html from a W3C recommendations page.

Presumably http://www.w3.org/TR/html4/struct/global.html#h-7.5.4
But oh, maybe not. It''s not the exact same. Where did you find that?

>
<P>aaaaaaaaa<DIV>bbbbbbbbb</DIV><DIV>cccccccc<P>dddddddd</DIV>

2.Although I didn''t think it would make any difference, I tried it
with the </p>s included as well.

<P>aaaaaaaaa</p><DIV>bbbbbbbbb</DIV><DIV>cccccccc<P>dddddddd</p></DIV>
FF2 renders both #1 and #2 as:
------------------
aaaaaaaaa

bbbbbbbbb
cccccccc

dddddddd

So it looks like FF2 doesn''t allow either <div>s within a <por <p>s
within a <div>??? Is there some other explanation? FF is either
putting a double break (<br><br>) after the <pterminates or a single
break after the <pand another single break before the following
<div>.

Kent,

Forget about breaks. Forget about <br>. They are just confusing you.

Add a <br>, singly, inside a paragraph, only if you want the paragraph
to break to the next line. Otherwise, never. Forget about them, and the
spacing-ness of them.

What you are seeing, or at least looking at, is the case where <p>
elements are automatically terminated. When the browser is reading
through the aaa''s, preparing to render that <p>, it bumps into a <div>
and realizes it should terminate the paragraph and start a new block
item, the div.

Read <http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.1>.

Now, *it happens* that individual browsers have certain default vertical
spacings before and after certain elements, including <pand <div>, and
*it happens* that these may appear to be common among several browsers,
it may also *look* as though the spacing is the equivalent of, say, the
result of inserting <brinto the source, but FORGET ALL OF THAT. Just
mark up the content, and style the elements for the spacing you''d like
to recommended.

Could the second <divbe terminating when it hits the <p>? It
looks like it.

I think the div isn''t terminating, but a paragraph is starting. Your
browser probably has a default vertical spacing before the <p>. There it is.

>
It looks like in IE7 a <pCAN contain a <div>

I don''t think so. <divis block-level markup. But a <pcannot contain
block-level elements:
http://www.w3.org/TR/html4/struct/text.html#edef-P

I don''t know why IE6 and IE7 are different, exactly, but different
browsers are, well, different. Are you in quirks mode? Or what?

HTH
--
John


On 12/19/2006 02:09 PM, Kent Feiler wrote:

1. Here''s some html from a W3C recommendations page.

<P>aaaaaaaaa<DIV>bbbbbbbbb</DIV><DIV>cccccccc<P>dddddddd</DIV>

2.Although I didn''t think it would make any difference, I tried it
with the </p>s included as well.
<P>aaaaaaaaa</p><DIV>bbbbbbbbb</DIV><DIV>cccccccc<P>dddddddd</p></DIV>
FF2 renders both #1 and #2 as:
------------------
aaaaaaaaa

bbbbbbbbb
cccccccc

dddddddd

So it looks like FF2 doesn''t allow either <div>s within a <por <p>s
within a <div>??? Is there some other explanation? FF is either
putting a double break (<br><br>) after the <pterminates or a single
break after the <pand another single break before the following
<div>. Could the second <divbe terminating when it hits the <p>? It
looks like it.

W3C says that most browsers will show the first one as:
----------------------
aaaaaaaaa
bbbbbbbbb
cccccccc

dddddddd

....which is how IE7 shows it.
IE7 renders #2 as:
-----------
aaaaaaaaa

bbbbbbbbb
cccccccc

dddddddd
It looks like in IE7 a <pCAN contain a <divwhich accounts for the
difference between #1 and #2 when we add the </p>s. The <pin #1
probably doesn''t end until it hits the second <p>.

I was surprised by these results.

Regards,
Kent Feiler
www.KentFeiler.com

A <pelement can only contain inline elements and text:
http://www.w3.org/TR/html4/struct/text.html#h-9.3.1

I might be inclined to say that FF is right, but I''m not sure.
--
pa*******************@earthlink.net
http://home.earthlink.net/~mumia.w.18.spam/


这篇关于&LT; p为H.和&lt; div&gt;和休息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆