Html CSS选择器的优先级

Html CSS选择器的优先级,html,css,Html,Css,这是我的HTML: <input type='submit' class='clsname'> 但这会为该输入生成一个红色边框: 我不知道确切的原因,但我知道这与选择器的优先级有关。我认为input[type='submit']的优先级高于classname,但input的优先级并不高于classname 现在我有了这样一个选择器:input[type='submit'],我需要给类名赋予更高的优先级。我该怎么做?我的意思是这样的: input[type='submit'] {

这是我的HTML:

<input type='submit' class='clsname'>
但这会为该输入生成一个
红色
边框:


我不知道确切的原因,但我知道这与选择器的优先级有关。我认为
input[type='submit']
的优先级高于classname,但
input
的优先级并不高于classname

现在我有了这样一个选择器:
input[type='submit']
,我需要给类名赋予更高的优先级。我该怎么做?我的意思是这样的:

input[type='submit'] { }
.clsname { /* bigger priority here */ }

注意:我可以通过
来完成!重要信息
,但我想知道还有其他方法吗?因为使用
!重要信息
不建议使用。

您可以有意对选择器进行过度限定,以赋予其更高的优先级

input[type="submit"].clsname

这是一种特殊性。阅读更多


使用
输入[type='submit'].clsname、.clsname
选择器


以下是。

使用
输入[type='submit'].clsname、.clsname
。谢谢。。。正如我在评论中所说,这正是我所需要的+1.
input[type='submit'] { }
.clsname { /* bigger priority here */ }
input[type="submit"].clsname