Multiple classes setting the same CSS property


I have a SPAN that i am styling to align text in the center of a div. The style looks like this:

   display: block;
   text-align: center;

My problem is that i have an invisible class that sets elements display property to none.  I use this quite often to show/hide elements.  But if i apply both classes to the span: ie,

.invisible { display: none; }
<span class="message invisible"></span>

..then the message class's display is overriding the invisible classes, so the span's display is set to block instead of none.

How can i get this to work, and what is rules does CSS use to choose which rules gets applied?

Kind regards,
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Try this:

.invisible {
display: none!important;

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's because span.message has a higher specificity than just .invisible.

If you make it:

span.invisible {

.message {

It should work the way you want.

KennyTM's will work, because !important supercedes all specificity.

Given two classes with the same priority, the one defined later in the file is the one that will be used.  

Stormy's way is better, because if you need to override an !important rule, you need to define the overriding rule with !important AND have it appear later in the file, which gets messy.
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Xavior2K3Author Commented:
Ok, so if i had

span.invisible {


span.message {

... then span.message would override span.invisible because it appears after?
Xavior2K3Author Commented:
Ok thank you all for your help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.