当前位置: 动力学知识库 > 问答 > 编程问答 >

Is empty css rule needed

问题描述:

I have the following HTML:

<tr class="brand">.....

Depending on the user that is logged in, this "brand" class may not need to contain anything.

So I have different styles sheets for different types of users.

User1.css:

.brand {

display: none;

}

User2.css:

.brand {

}

Do I actually need to bother setting the .brand rule in User2.css?

Will it show up an invalid markup?

Thanks

网友答案:

No, you do not. An empty one will be evaluated the same as it not being there at all.

网友答案:

you do not need it. actually you should NOT have it, waste of space

网友答案:

There's nothing wrong in having another CSS file for custom rules if you really can't do otherwise.

Depending on your actual markup, the empty element could be not displayed, in this case you won't need the additional rule. But this is not always the case.

Alternatively you could put the different rules in the same file, just changing or adding a class to the html which will target the other rules, if you don't have excessive users.

网友答案:

You don't need to bother with an empty rule, it's not invalid but it's a waste of space and bandwidth. If you must specify a value, use display: table-tow;.

分享给朋友:
您可能感兴趣的文章:
随机阅读: