CSS 2.1 defines a specific order in which user-supplied style sheets' declarations must be honored [1]. This ordering makes a lot of sense to me: author normal overrides user normal, but user !important overrides author !important. Can extensions easily replicate this behavior if the spec-compliant code is purged from the selector matching engine?
You can see that this is already the case in Firefox for Android, for instance, where you can't supply a user style sheet (the firefox profile is inaccessible to a user without root anyways). If you do want to provide user styles, Stylish is the featured (and almost universally recommended) extension for adding them. As you can see in the docs[1], though, anytime your !important rule comes up against an author's !important rule and you lose, the only workaround is to get more specific.
(it should be noted, though, that while CSS 2.1 does specify the cascade order with a "must", the user being able to specify styles in the first place is a "may", so Firefox for Android and Chrome for Android (which still doesn't support extensions) are spec compliant, they just make overriding styles more work and more fragile in the face of author changes)
! isn't as simple as that. CSS is cascading. If there are conflicting ! then rule specificity would be taken into account. If the rules have similar specificity the last one evaluated wins. I imagine user extensions are loaded at the end so in that case they would win.
No. !important supplied by the user is always higher than !important supplied by the author (and the opposite is true for non-!important), regardless of specificity. Specificity only comes into play when considering two rules supplied by the user or two rules supplied by the author.
If user agent style sheets are removed from the engine, then extensions will have to start considering specificity when adding style sheets to the end of the list, because they'll all be considered "author" rules. But user style sheets shouldn't have to worry about specificity, per the spec.
Yes I understand, but I wouldn't want that in a chrome extension personally. It could make styling harder. When you nuke rules without considering specificity it can cause unintended consequences. If everything just followed regular CSS rules as if all CSS was applied by the author there would be less of a chance of changing something you hadn't intended to change.
The people who use user style sheets (especially !important rules) in CSS aren't particularly interested in your styling. They're interested in the content in a style that works for them.
This is an important accessibility feature of CSS and I'm disturbed at any reduction in support for this feature.
It's trivial to write your own stylesheet. Create a directory, put a manifest.json with a content_scripts and a css attribute plus a matching attribute and then your css file. Like this:
This is why developers need to REALLY understand they are not like other people when building product
-----
1)Create a directory [fair enough]
2)put a manifest.json
2a) Add content_scripts
2b) css attribute
2b) plus a matching attribute and
3)css file.
4)Turn on developer mode
5) Load directory
As author of Safari User CSS extension[1], most of support email I've ever got are from non-developers. There are many kind I can recall, from those who simply want to adjust font sizes of a site permanently, to following tutorials on website on how to customize YouTube layout, to those that wrote userstyles on their own. I even got questions like "how do I turn Google black"/"how do I remove x from this url" sometimes.
I'm not sure about Chrome, but Safari had a similar feature but it lacked a way to scope stylesheets to certain domain. If Chrome userstyles behaves the same way then I don't think this change will affect those users anyway since being able to scope userstyles to certain domain seems very important to them.
> Do you really think non-developers are creating user stylesheets to begin with?
Then ask yourself why they are called user stylesheets?
IMHO all these attempts at taking away features "because most of the users won't ever use them" or similar reasons, and then saying "but developers can just do {more complicated thing}, it's better" is a terribly wrong direction that a lot of software seems to be heading in.
"Most of the users won't ever use them" is definitely a valid observation, but how about the ones who do? They probably use them because they discovered that feature and decided to play with it more, learn about it, and found out how useful it could be. By removing them, many more who would've otherwise discovered them will not, they will have a harder time learning about these things that benefit them, and instead remain ignorant. I find this to be almost patronising.
I have seen more than a few Linux screenshots with customized Xdefaults and customized user stylesheets. Granted, they are advanced user, but they were not developers.
I am a non dev. I just tried the recipe provided by leobelle using the files provided in gist.github and it works fine. I had to change "matches" to use
"<all_urls>" though. -------------------
Now I get a popup whenever I start Chrome telling me to disable developer mode extensions -- how to get rid of that?
Maybe only developers would write CSS from scratch, but there are plenty of non-devs who are capable of finding CSS snippets (e.g. on userstyles.org) and adding it to some sort of user stylesheet. However, once they're lost once the process gets beyond "find your user stylesheet at this path" or "click to install with Stylish."
Are you implying that "non-developers" should be discouraged from doing so? Would you agree if CSS was replaced with HTML?
Consider that many people learned how to write their own webpages with nothing more than a browser and a text editor, and the simplicity and soft error recovery characteristics of HTML is what I think was responsible for a large part of the Internet's growth. The barrier to entry was low, so it was easy to participate. Many people I know learned how to create webpages this way, largely by example (i.e. view source). Many of them also learned a bit of CSS too. These users produced and consumed content. But now, all I see is a growing divide between "users" and "developers", with these changes in browsers both reflecting and encouraging it, and I can't see that as being at all a good thing.
The problem with Stylish is the same problem with every other chrome extension. It can access all your data on all websites. It can surreptitiously autoupdate. I wouldn't want a person I knew to look over my shoulder while typing in my banking password, but I'm going to trust this extension with everything? I have ghostery and ad-block plus, and that's scary enough. That's it, that and my own extensions. I don't know anything about who made Stylish.
I have this exact problem with a lot of extensions I would like to use, so I only actually use one that extension which I implicitly trust anyway, LastPass. Here's an example, I use both Mac and Linux but on Linux I would like to have a more native looking scrollbar. Such functionality exist as extensions but I really do not want to trust a scrollbar plugin to have access to all data on all my websites (this is the permission required). I have been slowly (painfully) moving back towards Firefox recently just because on Linux Chrome is so out of place, but the Chrome Dev Tools are still way better.
I assume that Google is giving me a free browser because it will drive traffic and revenue to the search engine. There is no reason for Google to be nefarious to make money.
I cannot guess the motivations of free plugin developers.
Google's most valuable asset is its reputation; switching cost are still pretty low for most of their properties. But, not only does Google have a disincentive for being nefarious in that fashion, they're also under more scrutiny vis-à-vis Chrome (which would be effective even if it were not open source).
That's awesome. Never knew that, though admittedly I've not really immersed myself in how Chrome extensions actually work. Thanks for the example! Learn something new everyday :)
Is this hostile to users who need custom CSS for accessibility? Or do those users do something else entirely?
I sometimes wish Google would release numbers when they make changes. Finding out how many people used the plus operator (and how many of those used it correctly) made Google's removal of it slightly easier.
Edit: the + operator for searching, apologies for not being clear.
> Is this hostile to users who need custom CSS for accessibility?
Its just plain hostile to users. Accessibility is just one of the many ways it is hostile to users. (Generally, the designer-centric app-ification of the web which has been going on for since commercial interests other than those whose interest was in selling access to the internet first discovered the value of the internet to reach the public is user hostile, and this is just part of it.)
As someone that likes to pretty much always override author's styles, Chrome is pretty much out for me. There is no easy way in the browser settings to select your own stylesheet. Also there is no easy way to just turn off the author's stylesheet. Doing so can be quite useful for troublesome sites. In Firefox it's View -> Page Style -> None. But even that's obtuse. Not being able to easily flip between stylesheets in the browsers - has meant that author's can't really be bothered to supply them. Having some free well rounded Core styles, that users can apply to any site would be a nice to have feature in the browser, or alternatively making it very simple to add your own.
Opera is the only browser that felt like it let me apply my own stylesheet. Other browers behave inconsistantyl when adding my own. Even Firefox is odd. My compromise is just to specify foreground and background colours, with a larger font size, and an easy to read font. That way the layouts don't get that borked. Reading a well designed page with logical flow off can read quite well, if you apply your own styles, or use your desktops.
Here's something that has seemed to change in the newest Chrome: When I click the "+" (New Style Rule) in the inspector to add a new style to an element (let's say the element has a class of ".my-element"), in previous versions of Chrome, it would create an empty style like .my-element {}.
Now, when I do that, it creates "body > center > table > tbody > tr:nth-child(3) > td > table:nth-child(4) > tbody > tr:nth-child(1) > td > table > tbody > tr > td.default > span > font > p > a"
What happened here? Does that have anything to do with this User Stylesheet stuff? Because this new functionality is infuriating and I don't even really know what to search for to fix this change.
Probably an attempt at ensuring the properties you're about to add will apply to this and only this element and not any element of the .my-element class.
> -The user-stylesheet feature requires the user to put a CSS
stylesheet in the right location in their user-data-dir.
Extensions are a much better way of doing this.
Uh ? Why remove that feature ? It's not buggy, unmaintainable or resource hungry.
At root this is a part of the push to make the web less participatory and more like television. Users need to be gulping content and crapping cash, and they don't need to be distracted by trivia such as altering a web site's layout for personal usability or accessibility.
I doubt it's part of some huge conspiracy. I think they removed it to clean up some code after looking at the numbers of how many people actually used it.
There is a difference between "emergent behavior that looks remarkably like a huge conspiracy but really isn't", and "huge conspiracy." Either way, the trend is real.
Except that Chrome users aren't allowed to install extensions from outside the official Chrome extension store anymore (and the ones inside the Chrome app store aren't exactly trustworthy due to auto-update and creators transferring ownership to adware companies - especially small single-site extensions that sell cheaply).
Extensions are not a much better way of doing what CSS is designed to do as its normal mode of operation. Requiring extensions to do this is user-hostile.
As the commit message stated, the current method (of dropping just the right file in a usually hidden part of the filesystem) is fairly user hostile as it is.
Extensions exist which make this significaly friendly to all involved, such as Stylish.
> As the commit message stated, the current method (of dropping just the right file in a usually hidden part of the filesystem) is fairly user hostile as it is.
Right, there should be a basic UI setting to do load an specified stylesheet as the default.
That doesn't excuse removing basic functionality expected of a user agent out of the core and requiring an extensionto provide it at all, especially since that requires reducing security (by extending the number of trusted parties) to use that basic function.
"We didn't expose this basic function well enough by default" is a good reason to improve the UX related to the function, its not a good excuse to make the situation even worse.
Extensions (besides their other issues such as security) are also chrome-specific and require chrome-specific knowledge to write.
CSS stylesheets are nicely portable and should work in any (well, most) browser.
In general, a browser agnostic solution is preferable to a browser-specific solution, if they have the same functionality....
Stylesheets are also arguably much simpler to write, and far more concise for their problem space.
Maybe if user stylesheets didn't exist, you could say it isn't worth the effort to implement them, as javascript extensions are a "good enough" solution for a somewhat rare circumstance. But actually removing the existing, standardized, portable, feature seems a tad bizarre... [It's hard to believe it required much code.]
> In general, a browser agnostic solution is preferable to a browser-specific solution, if they have the same functionality....
This is a great point. If a user went through the trouble of creating custom styles to make certain sites accessible, browsers should follow a standardized way of managing these styles. Just like a user can import their bookmarks when changing browsers, styles should be handled similarly.
It might be extra effort for browsers to handle this uncommon feature, but it is the right thing to do, especially for users facing accessibility issues.
Not really. With user stylesheet (Custom.css), it was a local file you could edit with your favorite editor, and changes were live when you saved the file. I tried multiple extensions, and for all of them you need to paste your CSS in a box, click on a button to save it and reload the page to see any effects, which is quite painful compared to just typing :w<cr> in Vim.
It's well-maintained and allows a user to inject custom CSS or JS on any URL, domain or all sites for their own tweaks and purposes. Maintaining these overrides just one click away offers a much better experience than hunting down this Custom.css buried within the filesystem.
You can look at the source code of any extension, doesn't have to be released under OSI-compliant license. <Chrome Profile Folder>/Extensions/<extension code>.
I'd say ... write yours. The one which satisfies your needs and your needs only.
There are dozens of extensions which change the new tab page - I didn't like any of them, so I hacked a quick one myself - it took me 2h? 1.5h? It was fast and I didn't need any complicated features - just a CSS-styled table with fixed list of links and a clock.
Especially not Stylish. For example, I have a custom user style sheet which modifies the scrollbar so that it's high contrast. The current scrollbar contrasts very poorly and hard to see so it's a necessity.
When using the exact same CSS in Stylish, it breaks when going back/forward between pages all the time, rendering the default scrollbar instead. It's the same for every extension. I even wrote my own, it doesn't work.
Whoever decided to offload this capability onto extensions made a TERRIBLE decision.
Somewhat related, I've noticed not just Chrome, but most mobile browsers apply some sort of font boosting, inflation or some such... Isn't this breaking standards flagrantly? I know all these clever developers mean well [1], but still...
[1] Though I can't help feeling total arbitrariness when skipping from one first-level HN comment to the next.
[1]: http://www.w3.org/TR/CSS2/cascade.html#cascading-order