我们可以在选项元素中添加类属性吗? [英] Can we add class attribute in option element?

查看:83
本文介绍了我们可以在选项元素中添加类属性吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想为我的选项元素添加类。

I want to add class for my option element. Is that valid to add class attribute in HTML option element?

推荐答案

是的,它是有效的。

来自 W3School 网站:

The <option> tag also supports the Global Attributes in HTML.

从中属性是一个零件的。请注意,通常,选项标记具有关于您正在使用的浏览器的格式问题,因此样式可能有点棘手。

From which the class attribute is a part of. Please note that often, the option tag has formatting issues regarding the browser you are using, so styling it can be a little tricky.

编辑:由于我写了这个答案,它引起了我的注意, W3Schools可能不是最可靠的 信息来源。以前的答案并非完全错误,但它来自一个证明有些不一致/不完整的来源。因此,我想我还应该在这个主题上添加更多官方链接这里

Since I wrote this answer, it has come to my attention that W3Schools probably isn't the most reliable source of good information. The previous answer isn't at all wrong, but it came from a source that has proven to be somewhat inconsistent/incomplete. As such, I think I should also append a more official link to this subject here.

这篇关于我们可以在选项元素中添加类属性吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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