chiprivers Posted September 16, 2010 Share Posted September 16, 2010 Is it possible to make a CSS class take priority over any other conflicting declarations, irrespective of where the class is declared and the order in which it might appear? Quote Link to comment https://forums.phpfreaks.com/topic/213556-css-priority/ Share on other sites More sharing options...
haku Posted September 16, 2010 Share Posted September 16, 2010 Yes and no. Inline CSS will always take precedence over CSS in the <head>, which will in turn always take precedence over external CSS. But, for two selectors that are in the same area (both in the <head> or both in external files), you can increase the 'priority' by increasing the specificity (google 'css specificity'). Quote Link to comment https://forums.phpfreaks.com/topic/213556-css-priority/#findComment-1111632 Share on other sites More sharing options...
chiprivers Posted September 16, 2010 Author Share Posted September 16, 2010 Thanks haku. I am familiar with the 'specifity' of css but I was wondering whether there was a way of overiding this? Whether there was a command that could be included within a declaration that would make it a priority over any other normally prioritised contradicting declarations. Quote Link to comment https://forums.phpfreaks.com/topic/213556-css-priority/#findComment-1111731 Share on other sites More sharing options...
haku Posted September 17, 2010 Share Posted September 17, 2010 Not really... but if you want to make sure that your selector takes priority no matter what, you can put the CSS inline. But that's generally thought to be bad practice, as it means it can't be overridden! (except through javascript). Quote Link to comment https://forums.phpfreaks.com/topic/213556-css-priority/#findComment-1111996 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.