Skip to main content

Importance of !important in CSS

Do you know What does !important mean in CSS?, an "!important" declaration (the keywords "!" and "important" follow the declaration) this takes high precedence over a normal declaration. And can be framed in this way, this means that the styles are applied in order as they are read by the browser.

CSS it tries to create a balance of power between author and user style sheets. By default, rules in an author's style sheet override those in a user's style sheet. But in CSS1, this is in other way round - Author "!important" rules took precedence over User "!important" rules.


For Example:
User's Style Sheet:
    1: <style> 
    2:   p{font-size: 2em !important;} 
    3:   p{font-style: italic;} 
    4: </style>

Author's Style Sheet:
    1: <style> 
    2:   p{font-size: 3em;} 
    3:   p{font-style: normal;} 
    4: </style> 

If you see in the above instance, the first rule in the User's Style Sheet has "!important" declaration, which will overrides the first rule in the Author's Style Sheet. And if you observe for the second rule in User's Style Sheet it does not contain "!important" so this will be ruled out because here second rule in the Author's Style Sheet has got high preference so the HTML will render by taking size as "p{font-style: normal;}"

If you would like to know more on this, then check with the w3 site:
w3.org and move to the section called "6.4.2 !important rules"

Comments

Popular posts from this blog

Comma separated list of values of single Database table field

Many times you need to create a comma seperated list of values in a table. Here is a line of T-SQL solution to get comma separated list of values of single field of a database table. DECLARE @commaSeparatedVal AS VARCHAR(MAX); SELECT @commaSeparatedVal = ISNULL(@commaSeparatedVal +',','') + CONVERT(VARCHAR,[SKU]) FROM PRODUCT PRINT @commaSeparatedVal

Why SharePoint 2007?

It is rare for a technology product to attract as much attention as SharePoint has in recent years. The industry has historically paid little attention to new product suites, particularly those related to web design. SharePoint products and technologies, however, have managed to excite and rejuvenate industry followers, causing them to take notice of the ease of use, scalability, flexibility, and powerful document management capabilities within the product. A number of organizational needs have spurred the adoption of SharePoint technologies. Some of the most commonly mentioned requirements include the following: A need for better document management than the file system can offer —This includes document versioning, check-out and check-in features, adding metadata to documents, and better control of document access (by using groups and granular security). The high-level need is simply to make it easier for users to find the latest version of the document or documents they need to do th

Creating Custom SharePoint Timer Jobs

In previous versions of SharePoint (or other platforms), if you had some task you wanted to perform on a scheduled basis, you'd have to either create a console EXE and schedule it to run via Windows Task Scheduler (ala AT.EXE) or create a Windows Service that went to sleep for a period of time. In order to install (and maintain) these tasks, you had to have console access to your production SharePoint (or other app) servers... something IT or admins wouldn't easily hand out. Addressing this issue, Microsoft has added something called timer jobs to Microsoft Office SharePoint Server (MOSS) 2007. Microsoft uses timer jobs to do things like dead web cleanup (purging unused sites from site collections) among others. To see what other timer jobs are out there, from Central Administration , click Operations and then Timer Job Definitions . Not only does Microsoft use timer jobs in MOSS, but you can create your own custom timer jobs to do your own scheduled tasks. What's nice a