<风格>任何元素内的标签仍然可以工作? [英] <style> tag inside any elements will still work?

查看:75
本文介绍了<风格>任何元素内的标签仍然可以工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到类似这样的内容:

 < div> 
< style type =text / css>
...
< / style>
< / div>

非常奇怪,但仍然有效。

<这是违背标准的吗?

解决方案

值得指出的是,虽然它是无效的HTML,但它也非常常见,浏览器不支持它将无法正确呈现网络的重要部分。



特别是混搭,需要使用此功能,而HTML 5定义<样式范围>来处理这个用例。 <样式范围>可以出现在主体中,尽管如此定义的样式不适用于整个文档,只适用于< style scoped>部分。出现。



警告:HTML 5是草稿,并且不能保证< style scoped>或任何其他尚未实施的HTML 5功能都将实现。


I see something like this:

<div>
<style type="text/css">
...
</style>
</div>

It's very strange,but still work.

Is this against the standard?

解决方案

It's worth pointing out that although it's invalid HTML, it's also extremely common, and any browser that didn't support it would fail to render properly a significant portion of the web.

Mash-ups in particular, need use of this feature, and HTML 5 defines <style scoped> to deal with this use case. <style scoped> can appear in the body, though styles so defined do not apply to the whole document, only to the section in which <style scoped> appears.

WARNING: HTML 5 is a draft, and there is no guarantee that <style scoped> or any other HTML 5 feature that is not already implemented will ever be implemented.

这篇关于&LT;风格&GT;任何元素内的标签仍然可以工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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