添加多个类html [英] Adding more than one class html

查看:120
本文介绍了添加多个类html的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以在html中添加多个类?
这是我尝试过的操作:

Is it possible to add more than one class in html? Here is what i've tried:

<a href="#" class="class1" class="class2">My Text</a>

谢谢! :)

推荐答案

可以,但是只能声明 class 属性每个HTML元素一次。只需用空格分隔要应用的类。

Yes, it is possible, but you can only declare the class attribute once per HTML element. Just separate the classes you want to apply by a space.

<a href="#" class="class1 class2">My Text</a>

如果多次声明class属性,则除第一个定义外的所有定义都将被忽略,因此在您的代码 .class2 不会应用于您的链接。

If you declare the class attribute more than once, all definitions beyond the first will be ignored, so in your code .class2 will not be applied to your link.

这篇关于添加多个类html的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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