Hacker Newsnew | past | comments | ask | show | jobs | submit | rancyber's commentslogin

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


> 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 ) 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/ and 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.


Huh, 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.


It seems that chrome and chromium may also ignore the spec, as 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/pref...


Additionally, 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.


What 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.


I looked through the bug report and couldn't find the specification you're referencing. Do you have a link to it by any chance?


Just found it!

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."


If I read it correctly, what you just quoted is within the context of the <ruby> element.


I'm not really sure, but the thematic break element (<hr>) after the last paragraph mentioning ruby makes me believe its not.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: