嵌套完整,有效的HTML页面的合法性/实用性 [英] legality/practicality of nesting complete, valid HTML pages

查看:63
本文介绍了嵌套完整,有效的HTML页面的合法性/实用性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

人们


这是一个骨架,通用的HTML页面,称之为index.php。你会在中间看到一些

的PHP代码:


<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 Transitional // EN"

" http://www.w3.org/TR/html4/loose.dtd">

< html>


< head>

...

< / head>

< body>

....

<?php require(" another_page.html"); ?>

...

< / body>

< / html>


如果another_page.html的内容是有效的,它包含在外部

级别,< html ....< / html>。这意味着,当页面被提供时,

收件人浏览器将看到如下内容:


< html>

....

< html>

...

< / html>

。 ..

< html>


即完全嵌套 - 尽管其他方面完全有效 - HTML

文件。我已经读到这样做是一个不好的想法,但我找不到原因。
当然,HTML规范并没有说你可以做到这一点,但我可以'找不到任何地方

它说你不能。


好​​的,常识说你不应冒险给浏览器做一些不寻常的事情。

是的,绝对。


好​​吧,我已经把这样的文件嵌套好几个月了,我没有注意到

客户端出现任何问题。但是我正在寻找一个非常狭窄的测试

base:MacOS 10.4.x上只有FireFox。


问题1:这样的嵌套真的很糟糕IDEA?


你可能会猜到我有一个更深层次的问题。对!我设计了一个网站

,它有一个模板页面index.php,它使用php" require"动态填写
内容。我从.html

文件中放入了单独的内容块,所有这些文件都是独立有效的 - 以< htmland结尾

与< / html>开头。答对了!嵌套文件。


为什么我要使所有.html文件独立有效?因为Dreamweaver

(CS3)坚持。我不能正常运行WYSIWYG,也不能在网站范围内使用

CSS。我需要所有努力才能使这些块正确。


问题2:DHTML网站设计中是否一直出现这个问题?


问题3:我错过了一些非常明显的东西 - 或者是微妙的和

魔法 - 这会解决这个问题和/或教我放松一下吗?

TIA


Henry


删除''zzz''

Folks

Here''s a skeleton, generic HTML page, call it "index.php". You''ll see a bit
of php code in the middle:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
...
</head>
<body>
....
<?php require("another_page.html"); ?>
...
</body>
</html>

If the contents of "another_page.html" is valid, it contains, at the outer
level, <html .... </html>. That means, when the page is served up, the
recipient browser will see something like this:

<html>
....
<html>
...
</html>
...
<html>

That is, completely nested -- though otherwise completely valid-- HTML
files. I''ve read that doing this is a BAD IDEA, but I can''t find out why.
Sure, the HTML spec doesn''t say you can do this, but I can''t find any place
it says you can''t.

OK, common sense says you shouldn''t risk doing unusual things to browsers.
Yes, definitely.

Well, I''ve been nesting files like this for months, and I haven''t noticed
anything going wrong on the client. But I''m looking a very narrow test
base: only FireFox on MacOS 10.4.x.

Question 1: Is nesting like this really a BAD IDEA?

You might guess that I have a deeper question. Yup! I''ve designed a site
that has a single template page, index.php, which dynamically fills in
content using php "require". I put individual chunks of content from .html
files, all of which are stand-alone valid -- starting with <htmland ending
with </html>. Bingo! Nested files.

Why do I make all the .html files stand-alone valid? Because Dreamweaver
(CS3) insists. I can''t get functioning WYSIWYG, nor I can use site-wide
CSS otherwise. I need all that working to make the chunks right.

Question 2: Doesn''t this issue come up all the time in DHTML site designs?

Question 3: Am I missing something incredibly obvious --or subtle and
magic-- that will fix this and/or teach me to relax about it?

TIA

Henry

remove ''zzz''

推荐答案

2008-11-14,henry< he ************ @ gmail.comwrote:
On 2008-11-14, henry <he************@gmail.comwrote:

人们


这是一个骨架,通用的HTML页面,称之为index.php。你会在中间看到一些

的PHP代码:


<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 Transitional // EN"

" http://www.w3.org/TR/html4/loose.dtd">

< html>


< head>

...

< / head>

< body>

....

<?php require(" another_page.html"); ?>

...

< / body>

< / html>


如果another_page.html的内容是有效的,它包含在外部

级别,< html ....< / html>。这意味着,当页面被提供时,

收件人浏览器将看到如下内容:


< html>

....

< html>

...

< / html>

。 ..

< html>


即完全嵌套 - 尽管其他方面完全有效 - HTML

文件。我已经读到这样做是一个不好的想法,但我找不到原因。
当然,HTML规范并没有说你可以做到这一点,但我可以'找不到任何地方

它说你不能。
Folks

Here''s a skeleton, generic HTML page, call it "index.php". You''ll see a bit
of php code in the middle:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
...
</head>
<body>
....
<?php require("another_page.html"); ?>
...
</body>
</html>

If the contents of "another_page.html" is valid, it contains, at the outer
level, <html .... </html>. That means, when the page is served up, the
recipient browser will see something like this:

<html>
....
<html>
...
</html>
...
<html>

That is, completely nested -- though otherwise completely valid-- HTML
files. I''ve read that doing this is a BAD IDEA, but I can''t find out why.
Sure, the HTML spec doesn''t say you can do this, but I can''t find any place
it says you can''t.



它在DTD中存在 - 它说HTML元素必须包含一个HEAD和

a FRAMESET或者一个HEAD和一个身体。

It''s there in the DTD-- it says the HTML element must contain a HEAD and
a FRAMESET or else a HEAD and a BODY.


好​​的,常识说你不应该冒险给浏览器做一些不寻常的事情。

是的,绝对是。 />

好​​吧,我已经将这样的文件嵌套好几个月了,而且我没有注意到客户端出现任何问题。但是我正在寻找一个非常狭窄的测试

base:MacOS 10.4.x上只有FireFox。


问题1:这样的嵌套真的很糟糕理念?
OK, common sense says you shouldn''t risk doing unusual things to browsers.
Yes, definitely.

Well, I''ve been nesting files like this for months, and I haven''t noticed
anything going wrong on the client. But I''m looking a very narrow test
base: only FireFox on MacOS 10.4.x.

Question 1: Is nesting like this really a BAD IDEA?



是的。很多浏览器都知道如何修复它,所以你可以使用它,但是你已经在所有版本的IE上对它进行了详尽的测试吗?

Yes. Many browsers know how to fix it so you get away with it, but have
you tested it exhaustively on all versions of IE?


你可能会猜到我有一个更深层次的问题。对!我设计了一个网站

,它有一个模板页面index.php,它使用php" require"动态填写
内容。我从.html

文件中放入了单独的内容块,所有这些文件都是独立有效的 - 以< htmland结尾

与< / html>开头。答对了!嵌套文件。


为什么我要使所有.html文件独立有效?因为Dreamweaver

(CS3)坚持。我不能正常运行WYSIWYG,也不能在网站范围内使用

CSS。我需要所有努力使大块正确。
You might guess that I have a deeper question. Yup! I''ve designed a site
that has a single template page, index.php, which dynamically fills in
content using php "require". I put individual chunks of content from .html
files, all of which are stand-alone valid -- starting with <htmland ending
with </html>. Bingo! Nested files.

Why do I make all the .html files stand-alone valid? Because Dreamweaver
(CS3) insists. I can''t get functioning WYSIWYG, nor I can use site-wide
CSS otherwise. I need all that working to make the chunks right.



讽刺的是,它坚持有效性是导致你最终发布无效的HTML。

Ironic that its insistence on validity is what''s causing you to
ultimately publish HTML that''s invalid.


问题2:DHTML网站设计中是否一直出现这个问题?


问题3:我错过了一些非常明显的东西 - 或者是微妙的和

魔法 - 这会解决这个问题和/或教我放松一下吗?
Question 2: Doesn''t this issue come up all the time in DHTML site designs?

Question 3: Am I missing something incredibly obvious --or subtle and
magic-- that will fix this and/or teach me to relax about it?



好​​问题。这听起来好像不应该那么困难

过滤掉< htmland< / html当包含一个文件,但我知道

几乎没有关于php的内容。或者停止使用Dreamweaver和

将标签留下碎片(也许会自动将它们重新放入

以便验证它们)。

但是在你解决它之前你真的不能放松。所有的

都很麻烦然后麻烦,然后在它的末尾有无效的HTML。你不能责备这些工具。

Good questions. It sounds like it shouldn''t be that difficult to make it
filter out <htmland </htmlwhen including a file, but I know
practically nothing about php. Alternatively stop using Dreamweaver and
leave the tags out of your fragments (perhaps automatically putting them
back in for the purposes of validating them).

But you really can''t relax until you fix it. It''s no good going to all
that trouble and then having invalid HTML at the end of it. You can''t
blame the tools.




henry写道:

henry wrote:

>当然,HTML规范并没有说你可以做到这一点,但我不能找到它说你不能找到的任何地方。
>Sure, the HTML spec doesn''t say you can do this, but I can''t
find any place it says you can''t.



通过w3C验证器运行它。如果DTD *中包含的HTML规范

真的*不要说你不能这样做,那么它将验证没有错误。如果它抛出一个或多个b
更多的错误,那些就是你在做什么的地方

,HTML规范明确禁止。

-

Guy Macon

< http://www.GuyMacon.com/>

Run it through the w3C validator. If the HTML specifications
which are contained in the DTD *really* don''t say that you can''t
do that, it will validate with no errors. If it throws one or
more errors, those are the places where you are doing things
that the HTML specifications specifically forbid.
--
Guy Macon
<http://www.GuyMacon.com/>


henry schreef:
henry schreef:

人们


这是一个骨架,通用的HTML页面,称之为index.php ;。你会在中间看到一些

的PHP代码:


<!DOCTYPE HTML PUBLIC" - // W3C // DTD HTML 4.01 Transitional // EN"

" http://www.w3.org/TR/html4/loose.dtd">

< html>


< head>

...

< / head>

< body>

....

<?php require(" another_page.html"); ?>

...

< / body>

< / html>


如果another_page.html的内容是有效的,它包含在外部

级别,< html ....< / html>。这意味着,当页面被提供时,

收件人浏览器将看到如下内容:


< html>

....

< html>

...

< / html>

。 ..

< html>


即完全嵌套 - 尽管其他方面完全有效 - HTML

文件。我已经读到这样做是一个不好的想法,但我找不到原因。
当然,HTML规范并没有说你可以做到这一点,但我可以'找不到任何地方

它说你不能。


好​​的,常识说你不应冒险给浏览器做一些不寻常的事情。

是的,绝对。


好​​吧,我已经把这样的文件嵌套好几个月了,我没有注意到

客户端出现任何问题。但是我正在寻找一个非常狭窄的测试

base:MacOS 10.4.x上只有FireFox。


问题1:这样的嵌套真的很糟糕IDEA?


你可能会猜到我有一个更深层次的问题。对!我设计了一个网站

,它有一个模板页面index.php,它使用php" require"动态填写
内容。我从.html

文件中放入了单独的内容块,所有这些文件都是独立有效的 - 以< htmland结尾

与< / html>开头。答对了!嵌套文件。


为什么我要使所有.html文件独立有效?因为Dreamweaver

(CS3)坚持。我不能正常运行WYSIWYG,也不能在网站范围内使用

CSS。我需要所有努力才能使这些块正确。


问题2:DHTML网站设计中是否一直出现这个问题?


问题3:我错过了一些非常明显的东西 - 或者是微妙的和

魔法 - 这会解决这个问题和/或教我放松一下吗?
Folks

Here''s a skeleton, generic HTML page, call it "index.php". You''ll see a bit
of php code in the middle:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>

<head>
...
</head>
<body>
....
<?php require("another_page.html"); ?>
...
</body>
</html>

If the contents of "another_page.html" is valid, it contains, at the outer
level, <html .... </html>. That means, when the page is served up, the
recipient browser will see something like this:

<html>
....
<html>
...
</html>
...
<html>

That is, completely nested -- though otherwise completely valid-- HTML
files. I''ve read that doing this is a BAD IDEA, but I can''t find out why.
Sure, the HTML spec doesn''t say you can do this, but I can''t find any place
it says you can''t.

OK, common sense says you shouldn''t risk doing unusual things to browsers.
Yes, definitely.

Well, I''ve been nesting files like this for months, and I haven''t noticed
anything going wrong on the client. But I''m looking a very narrow test
base: only FireFox on MacOS 10.4.x.

Question 1: Is nesting like this really a BAD IDEA?

You might guess that I have a deeper question. Yup! I''ve designed a site
that has a single template page, index.php, which dynamically fills in
content using php "require". I put individual chunks of content from .html
files, all of which are stand-alone valid -- starting with <htmland ending
with </html>. Bingo! Nested files.

Why do I make all the .html files stand-alone valid? Because Dreamweaver
(CS3) insists. I can''t get functioning WYSIWYG, nor I can use site-wide
CSS otherwise. I need all that working to make the chunks right.

Question 2: Doesn''t this issue come up all the time in DHTML site designs?

Question 3: Am I missing something incredibly obvious --or subtle and
magic-- that will fix this and/or teach me to relax about it?



我认为你可以简单地使用< objectfor this。但是,像往常一样,不要期待IE的支持。


H.

-

Hendrik Maryns
http://tcl.sfs。 uni-tuebingen.de/~hendrik/

==================

提出聪明的问题,得到好的答案:
http:// www.catb.org/~esr/faqs/smart-questions.html


这篇关于嵌套完整,有效的HTML页面的合法性/实用性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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