我应该在相同的域iframe中使用head body和title标记吗?

时间:2021-05-09 15:55:01

I am loading contents into a same domain iframe. Does the html file that I am loading contents from need the head body html tags, or can i just put my content in a div and not worry about having it be a full page on its own? It will never be accessed on its own, and seems to work without those tags, but to work with all browsers are those tags necessary?

我正在将内容加载到同一个域iframe中。我加载内容的html文件是否需要head body html标记,或者我可以将我的内容放在div中,而不用担心它本身就是一个完整的页面吗?它永远不会被单独访问,而且似乎没有这些标签也能工作,但是要与所有浏览器一起工作,这些标签是必需的吗?

Thanks!

谢谢!

3 个解决方案

#1


4  

Treat it just like any other complete web page.

就像对待其他完整的网页一样。

#2


2  

While it may work without them, it's both semantically and syntactically better to include them.

虽然没有它们也可以工作,但是在语义和语法上包含它们都更好。

#3


0  

head, body and html tags are all optional in HTML anyway, so you're not doing anything wrong there.

head、body和html标签在html中都是可选的,所以你没有做错什么。

You should probably include a title element though. It's required for validity and may help with SEO if nothing else.

不过,您应该包含一个title元素。它对有效性是必需的,如果没有其他帮助的话,它可以帮助SEO。

#1


4  

Treat it just like any other complete web page.

就像对待其他完整的网页一样。

#2


2  

While it may work without them, it's both semantically and syntactically better to include them.

虽然没有它们也可以工作,但是在语义和语法上包含它们都更好。

#3


0  

head, body and html tags are all optional in HTML anyway, so you're not doing anything wrong there.

head、body和html标签在html中都是可选的,所以你没有做错什么。

You should probably include a title element though. It's required for validity and may help with SEO if nothing else.

不过,您应该包含一个title元素。它对有效性是必需的,如果没有其他帮助的话,它可以帮助SEO。