On web pages, users enter data via fields defined with the input tag. There are a few issues with this and a few more browser differences. By setting styles, most of this can be fixed (kludged out of existence).
In order to show before and after, mcUITools.css is not included in the page. Instead a slightly modified version is used where the classname is used to enable individual styles.
Spacing
Field | Tag | |
---|---|---|
Default | <input type="text" value="20" size="5" maxlength="6"> | |
Better | <input type="text" value="20" size="5" maxlength="6" style="padding-left: 2px;" > |
The element specification explicitly says which fields are affected because it should not apply to other input types (such as radio buttons).
input[type="text"], input[type="number"] { padding-left: 2px; } |
Sunken effect
Element | Default | Sunken | ||
---|---|---|---|---|
White | Grey | White | Grey | |
Select | ||||
Text | ||||
Readonly |
The Sunken effect is provided via css - the following also adds padding (a left gap) to the fields and changes the background color of the "readonly" fields.
input[type="text"], input[type="number"] { padding-left: 2px; } input[type="text"], input[type="number"], select { border-style: inset; border-width: 2px; border-color: #d0d0d0 #dedede #e0e0e0 #e8e8e8; } input.mcDisplay { width:80; box-shadow: 0 0px 0px 0px; background-color: #f0f0f0; border-color: #d0d0d0 #dedede #fbfbfb #d0d0d0; } |
Readonly vs Disabled
Comparison of readonly vs disabled |
| ||
---|---|---|---|
Readonly | Disabled | ||
Screen captures | ||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Browser | Image | Disabled colors | Comments | |||||||||||
Background | Text | |||||||||||||
Chrome 49 Windows XP |
#ebebe4 | #545454
| Neither field is sunken | The disabled text is readable Font size: 16px/13.3333px Chrome 50 | Windows 10
| #ebebe4 | #545454
| Both fields are raised
| Font size: 16px/9.33333px Firefox | Windows XP
| #ece9d8 | #aca899
| Both fields are rendered as sunken | The disabled text is too hard to read Font size: 16px/13.3333px |
Sunken style details
In the first 2 sections of following table, each row adds a new style so that the effect of each is visible. In the Compare section, various style combinations are used to make a point (not always obvious). To see the styles for a field, right click it and select inspect.
Style | Background | Comment | ||
---|---|---|---|---|
White | Grey | |||
Read/Write Text | System default | |||
padding-left: 2px; | This just indents the text a bit | |||
border-style: inset; | Chrome 49 default, not sunken Firefox 24 renders this as sunken | |||
border-width: 2px; | Chrome 49 default - no change | |||
border-color: #d0d0d0 #dedede #e0e0e0 #e8e8e8; | Add shadows, renders as sunken in Chrome 49 No effect in Firefox 24 | |||
Readonly | background-color: #f0f0f0; | New background color | ||
border-color: #d0d0d0 #dedede #fbfbfb #d0d0d0; | Lighten bottom shadow, darken left | |||
box-shadow: 0 0px 0px 0px; | On Chrome, this makes no difference - big difference with Firefox | |||
Compare | border-color: #d0d0d0 #dedede #fbfbfb #d0d0d0; | Text with readonly shadow, bottom edge hard to see | ||
box-shadow: 0 0px 1px 0px; | Text with readonly shadow, bottom edge easy to see | |||
box-shadow: 0 0px 1px 0px; | Text with read/write shadow, bottom edge easy to see - same styles as above - remove or edit | |||
box-shadow: 0 0px 1px 0px; | Readonly background with read/write shadow, bottom edge easy to see but a bit dark with a grey background |
This table compares the sunken effect colors.
Border | Firefox both | My read/write | My readonly | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
top | 828177 d0d0d0 | d0d0d0
| right | f9f8f3 | dedede | dedede
| bottom | f9f8f3 | e0e0e0 | fbfbfb
| left | 828177 | e8e8e8 | d0d0d0
| |
Digging deeper into Firefox, there is a jar file that contains the default style sheets. In them, colors are referred to as ThreeDShadow, ThreeDHighlight, ButtonFace, and the like. (Lots of examples) As far as I can tell, these color names are internal only and not supported by any standard. There is also a proposal that CSS provide variables to help solve this problem - but it has not been implemented.
border-style: inset;border-width: 2px; is the Chrome default on Windows XP.
Font Size
This is a test table - there are 2 input fields rendered as sunken on a grey background. (What I use for my designs.) They are identical except that one has the size set via a style.
Comparison of default and set font |
| ||
---|---|---|---|
Default | 13.33px | ||
Unfortunately, CSS does not provide a way to make the fonts in one style the same as that in another. Therefore, I could use javascript.
For text on the page | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Style | Chrome 49 XP | Firefox 24 XP | Microsoft Edge Windows 10 | IE 11 Windows 10 | Chrome 50 Windows 10 | ||||||
|
|
|
|
|
|
For text in an input field | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Style | Chrome 49 XP | Firefox 24 XP | Microsoft Edge Windows 10 | IE 11 Windows 10 | Chrome 50 Windows 10 | ||||||
|
|
|
|
|
|
So - Is the problem Windows, Chrome, or something else? I don't have enough data points to make a claim. Whatever it is - It Sucks!!
I used IE and Microsoft Edge with Windows 10 simply to add additional data points. Since neither has the same problem as Chrome 50, it seems pretty obvious that the problem is Chrome - period. However, many other programs (not mentioned here) work fine in Windows XP but also have font size problems with Windows 10. Therefore, I am still not sure where to place the blame.
Again, the basic rule is - Don't trust the defaults!
Other Components
/* This is needed for Chrome 50 on Windows 10, font size would be 9.33333px without this */ input[type="text"], input[type="number"], input[type="button"], select, textarea, button { font-size:13.3333px; } |
3 additional components | |||
---|---|---|---|
Control | Default Code | ||
Default | Sunken and size=13.33px | ||
| |||
|
Chrome CSS Confusion
input[type="text" i] { tags go here } |
Expected ']' to terminate attribute selector but found 'i'. Ruleset ignored due to bad selector. |
the Chrome browser is based on WebKit. There are some webkit internal font setting options for font family, font size, etc. |
Documents and Settings\[username]\Local Settings\Application Data\Google\Chrome\User Data\Default\Preferences |