4 ms·
This is the browser's fault for violating the HTML spec. As per the specification, the default font color is complete black and the default background color is
by rancyber 8y ago
This is the browser's fault for violating the HTML spec. As per the specification, the default font color is complete black and the default background color is complete white. To my knowledge the only browser that does not honor this is Firefox[1], and it is an eighteen year old bug which they refuse to fix.
[1] https://bugzilla.mozilla.org/show_bug.cgi?id=70315 https://bugzilla.mozilla.org/show_bug.cgi?id=70315
- luuio 8y agoI looked through the bug report and couldn't find the specification you're referencing. Do you have a link to it by any chance?
- bilkow 8y agoJust found it! https://html.spec.whatwg.org/multipage/rendering.html#phrasing-content-3 https://html.spec.whatwg.org/multipage/rendering.html#phrasi... "The initial value for the 'color' property is expected to be black. The initial value for the 'background-color' property is expected to be 'transparent'. The canvas's background is expected to be white."
- bilkow 8y agoIt seems that chrome and chromium may also ignore the spec, as https://news.ycombinator.com/item?id=19056637 https://news.ycombinator.com/item?id=19056637 says. Hopefully prefers-color-scheme[0] will take over soon. [0] https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-color-scheme https://developer.mozilla.org/en-US/docs/Web/CSS/@media/pref...
- twhb 8y agoAdditionally, the “prefers-color-scheme” media query exists, which is the standard way to bring dark mode to the web and solves all the issues listed in the article by being opt-in. Firefox hasn’t implemented it, but neither has anybody but Safari yet.
- chriswarbo 8y ago> This is the browser's fault for violating the HTML spec. As per the specification, the default font color is complete black and the default background color is complete white. Your claim surprised me so much I went and re-read the latest HTML spec ( https://www.w3.org/TR/html52/rendering.html#rendering https://www.w3.org/TR/html52/rendering.html#rendering ) and it does indeed say: > The initial value for the color property is expected to be black. The initial value for the background-color property is expected to be transparent. The canvas' background is expected to be white. The CSS specs ( https://www.w3.org/TR/2018/REC-css-color-3-20180619/ https://www.w3.org/TR/2018/REC-css-color-3-20180619/ and https://www.w3.org/TR/2011/REC-CSS2-20110607/colors.html#q14.0 https://www.w3.org/TR/2011/REC-CSS2-20110607/colors.html#q14... ) say that the initial values depend on the user agent (hence deferring to the above quote): > Name: color > Initial: depends on user agent > 'background-color' > Initial: transparent However, is this also the case for form fields? Scanning through the various CSS specs I can't find any mention of form fields (e.g. buttons, text inputs, etc.). The HTML specs don't seem to specify anything w.r.t. styling form fields either.
- jameshart 8y agoHuh, kids today with their modern web standards with their sensible, well specified defaults. In my day, the default background color was #C0C0C0, as is laid down in the Book of Mozilla.
- bzbarsky 8y agoWhat you say is true for the default, but form controls have additional UA styles applied to them that can override the default. Just like the default border style is "none", but that's not what form controls do. But even past that point, this is the _ua_ default. A user can always have a user stylesheet that sets whatever colors the user wants (e.g. for accessibility reasons). And not setting background without setting color and vice versa is standard best-practice web development advice and has been for 2 decades or so now.