为什么CSS使用假的元素? [英] Why does CSS work with fake elements?

查看:80
本文介绍了为什么CSS使用假的元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的课堂上,我在玩耍,发现CSS使用的化妆元素。

In my class, I was playing around and found out that CSS works with made-up elements.

示例:

<style>
imsocool {
    color:blue;
}
</style>

<body>
    <imsocool>HELLO</imsocool>
</body>

当我的教授第一次看到我使用这个,他有点惊讶,化妆元素工作,推荐我只是把我所有的元素改成带有ID的段落。

When my professor first saw me using this, he was a bit surprised that made-up elements worked and recommended I simply change all of my made up elements to paragraphs with ID's.

为什么我的教授不想使用化妆元素?他们有效地工作。

Why doesn't my professor want me to use made-up elements? They work effectively.

此外,为什么他不知道化妆元素存在并使用CSS。

Also, why didn't he know that made-up elements exist and work with CSS. Are they uncommon?

推荐答案


为什么CSS使用伪元素?

Why does CSS work with fake elements?

(大多数)浏览器设计为(在某种程度上)向前兼容未来添加的HTML。无法识别的元素被解析到DOM中,但没有语义或与它们相关联的专门的默认渲染。

(Most) browsers are designed to be (to some degree) forward compatible with future additions to HTML. Unrecognised elements are parsed into the DOM, but have no semantics or specialised default rendering associated with them.

当一个新的元素添加到规范时,有时CSS,JavaScript和ARIA可用于在旧版浏览器中提供相同的功能(并且元素必须出现在DOM中,以便能够操作这些语言来添加该功能)。

When a new element is added to the specification, sometimes CSS, JavaScript and ARIA can be used to provide the same functionality in older browsers (and the elements have to appear in the DOM for those languages to be able to manipulate them to add that functionality).

(虽然应该注意,正在开发工作来定义一种方法来使用自定义元素扩展HTML ,但这项工作目前处于发展的早期阶段,因此应该避免,直到它成熟为止。)

(Although it should be noted that work is underway to define a means to extend HTML with custom elements, but this work is in the early stages of development at present so it should probably be avoided until it has matured.)


我的教授希望我使用补充的元素?

Why doesn't my professor want me to use made-up elements?




  • / li>
  • 它们可能与未来同名的标准元素冲突

  • 可能有一个现有的HTML元素更适合任务


  • 为什么他不知道化妆元素存在并使用CSS。它们是不常见的吗?

    Also; why didn't he know that made-up elements existed and worked with CSS. Are they uncommon?

    是的。人们不使用它们,因为他们有上述问题。

    Yes. People don't use them because they have the above problems.

    这篇关于为什么CSS使用假的元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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