Closed Bug 1371361 Opened 9 years ago Closed 6 years ago

The Marvelous Dogmas of Nobody

Categories

(Developer Documentation Graveyard :: CSS, enhancement, P5)

All
Other
enhancement

Tracking

(Not tracked)

RESOLVED WONTFIX

People

(Reporter: fransua.lionel, Unassigned)

References

()

Details

:: Developer Documentation Request Request Type: Correction Gecko Version: unspecified Technical Contact: :: Details QUOTES: Location: <p> The !important exception Phrase 0: "Using !important, however, is bad practice and should be avoided [...]" further... Location: <p> You should use it when: Phrase 1: "You (or others) use inline styles on elements themselves. This is considered very bad practice." Phrase 2: "In this case, you could set certain styles in your global CSS file as important, thus overriding inline styles set directly on elements." STATEMENTS: Phrase 2 states exactly why !important has been featured: "To prevent inline styling ( by HTML writers )." Which in turn states why !important has been featured for: un-overridable layouts. But the community ( Phrase 0 ) stated: "Using !important, however, is bad practice and should be avoided [...]" Which states that the second sentence in phrase 1 is an opinion not consensuated by the community. Debate on good/bad/very bad practices is not to be the point here ( IMHO ). The article demostrates clearly what !important is MISTAKEN for: "a 'flag' to give a CSS rule a higher specificity", but only if we explicitely state its legitimate use: "To prevent inline styling ( by HTML devs/editors/generators... ) in "foreign-HTML" applications which could not or don't want to handle foreign-styled HTML. Or just to make it difficult to home-devs to customize a widget...", would it make sense its existence and observable behaviour. It´s the right place to do it, and it may help a reasoned/legitimate use of both specificity and !important features. Thanks for reading and considerating.
Fransua Lionel, MDN > Web technology for developers > CSS > Specificity > The !important exception https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity#The_!important_exception MDN > Web technology for developers > CSS > Specificity > You should use it when: https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity#You_should_use_it_when First, it is always better (otherwise best) to give formal actual results and formal expected results. Quote what you believe to be contradictory and debattable (actual results) and then propose appropriate, suitable replacements to such quote (expected results). Right now, after reading your description, I am not sure what exactly should be replaced and with what you would replace. Second, the CSS 2.x spec indicates to sort declarations first by origin (media), then by importance and then by specificity. Here, you may want to quote whatever you believe would be helpful, useful, supporting your point of view (and your expected results) for this bug report and give an URL. 6.4.1 Cascading order https://www.w3.org/TR/CSS21/cascade.html#cascading-order https://www.w3.org/TR/CSS22/cascade.html#cascading-order Third, I agree with you that the overall text is somewhat contradictory. - - - - - - - - My opinion on this issue: 1- I believe that resorting to, using external libraries, like Bootstrap or normalize.css or jQuery is a mistake, is an error of judgement, is generally bad, is not recommandable, etc... unless the author greatly trims down, reduces the number of selectors and declarations and only keep the selectors and declarations really needed for his website. There is such a thing as bloated style sheets, bloated CSS code, over-excessively over-declaring, over-defining, etc... 2- I believe using inline styles on elements themselves is unfortunately a very common, frequently seen practice but a bad practice, at least a not-recommendable practice. 3- "Using !important, however, is bad practice and should be avoided because it makes debugging more difficult by breaking the natural cascading in your stylesheets." : I agree with such statement but maybe I would add more on this. 4- "why !important has been featured for": I think the CSS2.x specifications do not even explain what is the correct and appropriate usage of !important author rules to begin with. If an user creates an user style sheet for his(her) needs (legibility needs, readability, viewing requirements, old eyes, handicaps), then why would he(she) not make all of his declarations !important? Why would he(she) give an opportunity to author style sheet normal declarations to override the normal declarations of his(her) user style sheet? I have develop myself a few user style sheets for some of the websites I visit regularly and my user style sheets for those websites all use !important declarations.
Hello, To Gérard Talbot: I fully agree with point 1. I can agree with point 2, if we explicitely not-recomend ( for scaling/SOC purposes ), and not state as bad practice ( to see as deprecated ). I'd like to agree with point 3, but as you stated in point 4, !important is USEFULL and the only way to succesfully layout foreign/unknown-HTML. Replacement proposal: << Using !important, however, is probably not necesary and should be avoided since it breaks the cascading nature of stylesheets (CSS), making reading/debugging more difficult. >> << As a disclaimer, CSS2.x specifications do not explicitely state what is the correct and appropriate usage of !important. As a disclaimer, HTML syntax by nature does contain/infers layout, and CSS requires the !important feature to simulate/achieve SOC. You should use it when: - The CSS is (to-be-used-as) a (main? single? only?) layout library. - The HTML is (to-be-used-as) data with no/minimal layout. You might define as simple examples : * { font-family: Arial, Helvetica, sans-serif !important; } /* No strange fonts */ * { color: white !important; } /* No strange font colors */ a { color: blue !important; } /* But links */ >> You may think of more explicits examples, however I deliberately used simulate/achieve and no/minimal, to point out that trying to strip layout from HTML and then lay it out with !important is still somehow a hack for SOC. Thanks again for reading and considering.
Just a comment on the motives for the modification request, The "You should use it when" section has to be there, and deserves exactly what Gérard Talbot wrote in its point 4. Link to W3C is definitely more explicit but: - few UA devs look for answers in MDN when lots of web content devs do. Am I right? - User stylesheets are usually not text typed but generated by UA and receive the !important opaquely/globally. Am I right? Then our main use cases, author's stylesheets are, I repeat, exactly what Gérard Talbot wrote in its point 4. Our mistake pointing at inline styling. Thanks.
To be more explicit, what Gérard Talbot pointed at in its point 4 is exactly the re-layout "foreign-HTML" case, no matter re-serving it or by UA, which would be imposible without !important, and when in such a case, every rule is to be !important.
First of all, if the bug form, in the case of documentation change request, requires a "ready to copy-paste" solution, state it explicitely, since defining rules a posteriori, even in a conversation, is a good example of cheating. Second, if the bug form can not diferentiate a documentation change request of a bug on last beta, I can make an offer to fix that for you. Third, there are more than 30 credited authors for this article, and obviously none of them ready to argument its statements. What are they credited for? The copy-paste work? Fourth, the quotes: "Using !important, however, is bad practice [...]" "You (or others) use inline styles on elements themselves. This is considered very bad practice." "In this case, you could set certain styles in your global CSS file as important, thus overriding inline styles set directly on elements." just demostrate that the 30+ authors: - were not able to state why !important is implemented. ( use cases ) - were not able to state what !important actually does. ( specs ) - do not even understand why a documentation is written.( it´s not a blog, nor a pupil's book ) By the way, the article is tagged beginner, so which tag got the color feature article? "CSS master" or "Style Genius"? Or should I understand "written by beginners"? Fifth, the quote: "Some badly written jQuery plugins which use inline styles." just demostrate how far from subject and inapropriate gets the article, what about badly written MDN articles or the poorly broadcasted Olympics in Rio? Sixth, what comes from "You should use it when" until the end of the article is not only misleading but clearly absurd. My conclusion: If the goal of this article is leading MDN documentation users to absurd SO debates, keep on the good job. If the goal of this article is leading MDN documentation users to move to W3C, or whatever beta SO documentation, keep on the good job. If the goal of this article is explaining specificity and the !important feature, ANYBODY who actually HAD TO use !important will give a STRAIGHTFORWARD and SOLID answer: It´s the only way to do it, so who cares you don´t like it. End of conclusion. Post Data: As the article promotes the debate on inline styling being a very bad practice, I'd like to directly ask Gérard Talbot, who agrees with that, and anybody willing to answer these questions: Can you give any argument for that, other than my boss wants or X said? Do you think the same for every presentational atributes? Do you consider that 20+ years after CSS2, still not every HTML layout feature is available to it? Do you consider that HTML was designed to be both the layout declaration and content container, so if you feel concerned by SOC, you can easily use HTML as only one of those, or simply don´t use it, who cares you don´t like it, UAs can render lot more things than HTML. Destroyers generally outnumber builders and obviously focus on what´s built, not on what´s to build, even if they call themselves developers. When you actually HAVE TO use !important, do you consider you are implementing "bad practice", do you feel like doing something the wrong way? Lots of self-declared CSS gurus stated table tag was bad practice as far as 15+ years ago, where are they now? still obfuscated trying to make CSS as straightforward as HTML? They might make it, but only then could we begin to think about if/when to deprecate the table tag. And just to point out the absurdness of this debate: Would you bully the img tag and background all your images in divs if any MDN author wrote it is a very very bad practice? If it happened now, when do you think UAs would definitely stop implementing it? And when this happens, what will you think about your piece of code by then? Information may becomes obsolete, but how to spread it is always contigent. If you believe that your layout will be the MUST in 2050, don´t write CSS, paint it! In my opinion, if you don´t like HTML, forget about CSS, learn image/video edition, PowerPoint, or watercolor. And if you look for a binary job, right/wrong, programing, even CSS, is wrong, since you will face decisions based on flavour: speed/precision, size/readability, delivery/correctness, the simple task of naming something can lead to surprising nightmares, not even documentation is flavour-free. Selfish epitaph: I've been developing web contents since 1999, and, since available, used MDN as a trustable resource, and wandered in its articles just as a sometimes instructive entertainment. Until reading this article, I had only thanks and nothing to complain about, even if obviously my interpretation could differ a bit in some places. The appalling quality of this article just makes me nervous, since if this .... is there, I can not trust MDN anymore, somebody broke my toy. I was selfishly willing to fix my MDN toy, but I doubt I can, I may rename it as the Marvelous Dogmas of Nobody...
Summary: Please re-phrase to avoid contradictions and debates about !important → The Marvelous Dogmas of Nobody
(In reply to fransua.lionel from comment #3) > - User stylesheets are usually not text typed User style sheets are text. Example given of an user style sheet specifically designed for, targeted for the webpages of the wiki.mozilla.org domain from using Firefox's Stylish 2.0.7 extension ( downloadable from https://addons.mozilla.org/en-US/firefox/addon/stylish/ ): @namespace url(http://www.w3.org/1999/xhtml); @-moz-document domain("wiki.mozilla.org") { body { font-size: 100% !important; } } and that user style sheet will force the font size of the body text of all wiki.mozilla.org webpages to meet, to comply with *my* normal body text size as I set it in Firefox ( about:preferences#content ). It is possible to create an user style sheet that will apply to all webpages: people with visual color deficiency are the ones who would expectedly want to create and use one for their needs. "About 8 percent of all men have some form of color deficiency" https://msdn.microsoft.com/en-us/library/Bb263953.aspx#hess1009_topic2 > but generated by UA and > receive the !important opaquely/globally. Am I right? User style sheet can only be created, edited by an user. User style sheet do not receive an !important mark, keyword; only declarations can have an !important keyword. A normal (non-!important) author declaration will win over a normal (non-!important) user declaration. An !important user declaration will win over an !important author declaration. " Sort according to importance (normal or important) and origin (author, user, or user agent). In ascending order of precedence: user agent declarations user normal declarations author normal declarations author important declarations user important declarations " CSS 2.x, section 6.4.1 Cascading order https://www.w3.org/TR/CSS21/cascade.html#cascading-order https://www.w3.org/TR/CSS22/cascade.html#cascading-order
Thanks Gérard for replying to the Am I right question? I obviously was not. I also obviously now inform myself at W3C and Microsoft documentation just like you adviced. // Put more links I still think that legacy-called user stylesheets are, when thought as to be typed, a dev tool like the console: would you ask your USERS to fill a form by setting some JS variables in the console? And download a layout theme to install?? in the UA to see your site? As text to copy-paste? Obviously not. People that really NEED a (user stylesheet) global restyling obviously don´t type it. Just like they don´t write no C code to use Mozilla, they INSTALL it, as per example given. Someone had to write it obviously, but to be clear: My web USERS are not devs. They don´t use MDN/CSS/console nor any DEV thing. Of course, Bootstrap users are not Mozilla users nor my web app users. What CSS spec calls user agent is IMHO UA´s default config, and user is strictly UA, since no people: USER, is involved, but the only UA installed and CONFIGURED. Yes, specs users also include UAs devs and admins. Who are MDN documentation users supposed to be? It seems that this article is legacy from 1980´s first debates about CSS, SOC and legacy-called user(agent) stylesheets. It´s obvious to me that the latest HTML, CSS and UAs show that this debate, even if it is still around, had no effects on the evolution of any of them. The point is Why is this pointless antique debate in a MDN article?
As a comment on the global concept of !important in libraries and legacy-called user stylesheetes: 1: libraries: As a simple protection from overloading, you state all your declarations as !important. Then, to overload any rule you have to explicit the overload stating it as !important AGAIN. This is a web dev feature. 2: legacy-called user stylesheets: Normal declarations: They had to be somewhere in the cascading order: THE configurable DEFAULT. As these rules will be overloaded by any other, it´s more of use as a UA theme than a web dev feature. Global !important declarations: There is the UA accesibility feature: No rule must be ignored/overloaded, this is a global restyling. This is a UA feature. I really think that understanding !important in a global use context can help to answer where and why using !important. My point is: If the configurable default and the legacy-called user stylesheet were to be different files, a per file feature would cover those use cases. Any other? PD: I´ll check for that in LESS.
To be clear, it´s the oposite of SOC, Mixing of Concerns, what is often dogmatically stated as bad practice. In our case, mixing normal and !important declarations in the same FILE. However, it´s what the legacy-called user stylesheet expects. Consider the @-moz-document domain feature for example, and think a huge CSS file with all the urls of the sites you want your UA to restyle. You might realize that SOC/MOC is just a dev´s art and flavour, not a right/wrong thing, and is definitely not meaningfull enough to deprecate language features. In fact, it´s meaningless outside of its scope: the FILE system. "If the configurable default and the legacy-called user stylesheet were to be different files [...]"
MDN Web Docs' bug reporting has now moved to GitHub. From now on, please file content bugs at https://github.com/mdn/sprints/issues/ and platform bugs at https://github.com/mdn/kuma/issues/.
Status: UNCONFIRMED → RESOLVED
Closed: 6 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.