CSS property compatibility table for form controls - Learn web development 编辑

The following compatibility tables try to summarize the state of CSS support for HTML forms. Due to the complexity of CSS and HTML forms, these tables can't be considered a perfect reference. However, they will give you good insight into what can and can't be done, which will help you learn how to do things.

How to read the tables

Values

For each property, there are four possible values:

Yes
There's reasonably consistent support for the property across browsers. You may still face strange side effects in certain edge cases.
Partial
While the property works, you may frequently face strange side effects or inconsistencies. You should probably avoid these properties unless you master those side effects first.
No
The property doesn't work or is so inconsistent that it's not reliable.
n.a.
The property has no meaning for this type of widget.

Rendering

For each property there are two possible renderings:

N (Normal)
Indicates that the property is applied as it is
T (Tweaked)
Indicates that the property is applied with the extra rule below:
* {
  /* Turn off the native look and feel */
  -webkit-appearance: none;
  appearance: none;

/* for Internet Explorer */
  background: none;
}

Compatibility tables

Global behaviors

Some behaviors are common to many browsers at a global level:

border, background, border-radius, height
Using one of these properties can partially or fully turn off the native look & feel of widgets on some browsers. Be careful when you use them.
line-height
This property is supported inconsistently across browsers and you should avoid it.
text-decoration
This property is not supported by Opera on form widgets.
text-overflow
Opera, Safari, and IE9 do not support this property on form widgets.
text-shadow
Opera does not support text-shadow on form widgets and IE9 does not support it at all.

Text fields

See the text, search, and password input types.

PropertyNTNote
CSS box model
widthYesYes
heightPartial[1][2]Yes
  1. WebKit browsers (mostly on Mac OSX and iOS) use the native look & feel for the search fields. Therefore, it's required to use -webkit-appearance:none to be able to apply this property to search fields.
  2. On Windows 7, Internet Explorer 9 does not apply the border unless background:none is applied.
borderPartial[1][2]Yes
  1. WebKit browsers (mostly on Mac OSX and iOS) use the native look & feel for the search fields. Therefore, it's required to use -webkit-appearance:none to be able to apply this property to search fields.
  2. On Windows 7, Internet Explorer 9 does not apply the border unless background:none is applied.
marginYesYes
paddingPartial[1][2]Yes
  1. WebKit browsers (mostly on Mac OSX and iOS) use the native look & feel for the search fields. Therefore, it's required to use -webkit-appearance:none to be able to apply this property to search fields.
  2. On Windows 7, Internet Explorer 9 does not apply the border unless background:none is applied.
Text and font
color[1]YesYes
  1. If the border-color property is not set, some WebKit based browsers will apply the color property to the border as well as the font on <textarea>s.
fontYesYesSee the note about line-height
letter-spacingYesYes
text-alignYesYes
text-decorationPartialPartialSee the note about Opera
text-indentPartial[1]Partial[1]
  1. IE9 supports this property only on <textarea>s, whereas Opera only supports it on single line text fields.
text-overflowPartialPartial
text-shadowPartialPartial
text-transformYesYes
Border and background
backgroundPartial[1]Yes
  1. WebKit browsers (mostly on Mac OSX and iOS) use the native look & feel for the search fields. Therefore, it's required to use -webkit-appearance:none to be able to apply this property to search fields. On Windows 7, Internet Explorer 9 does not apply the border unless background:none is applied.
border-radiusPartial[1][2]Yes
  1. WebKit browsers (mostly on Mac OSX and iOS) use the native look & feel for the search fields. Therefore, it's required to use -webkit-appearance:none to be able to apply this property to search fields. On Windows 7, Internet Explorer 9 does not apply the border unless background:none is applied.
  2. On Opera the border-radius property is applied only if an explicit border is set.
box-shadowNoPartial[1]
  1. IE9 does not support this property.

Buttons

See the buttonsubmit, and reset input types and the <button> element.

PropertyNTNote
CSS box model
widthYesYes
heightPartial[1]Yes
  1. This property is not applied on WebKit based browsers on Mac OSX or iOS.
borderPartialYes
marginYesYes
paddingPartial[1]Yes
  1. This property is not applied on WebKit based browsers on Mac OSX or iOS.
Text and font
colorYesYes
fontYesYesSee the note about line-height.
letter-spacingYesYes
text-alignNoNo
text-decorationPartialYes
text-indentYesYes
text-overflowNoNo
text-shadowPartialPartial
text-transformYesYes
Border and background
backgroundYesYes
border-radiusYes[1]Yes[1]
  1. On Opera the border-radius property is applied only if an explicit border is set.
box-shadowNoPartial[1]
  1. IE9 does not support this property.

Number

See the  number input type. There is no standard way to change the style of spinners used to change the value of the field, with the spinners on Safari being outside the field.

PropertyNTNote
CSS box model
widthYesYes
heightPartial[1]Partial[1]
  1. On Opera, the spinners are zoomed in, which can hide the content of the field.
borderYesYes
marginYesYes
paddingPartial[1]Partial[1]
  1. On Opera, the spinners are zoomed in, which can hide the content of the field.
Text and font
colorYesYes
fontYesYesSee the note about line-height.
letter-spacingYesYes
text-alignYesYes
text-decorationPartialPartial
text-indentYesYes
text-overflowNoNo
text-shadowPartialPartial
text-transformN.A.N.A.
Border and background
backgroundNoNo

Supported but there is too much inconsistency between browsers to be reliable.

border-radiusNoNo
box-shadowNoNo

Check boxes and radio buttons

See the checkbox and radio input types.

PropertyNTNote
CSS box model
widthNo[1]No[1]
  1. Some browsers add extra margins and others stretch the widget.
heightNo[1]No[1]
  1. Some browsers add extra margins and others stretch the widget.
borderNoNo
marginYesYes
paddingNoNo
Text and font
colorN.A.N.A.
fontN.A.N.A.
letter-spacingN.A.N.A.
text-alignN.A.N.A.
text-decorationN.A.N.A.
text-indentN.A.N.A.
text-overflowN.A.N.A.
text-shadowN.A.N.A.
text-transformN.A.N.A.
Border and background
backgroundNoNo
border-radiusNoNo
box-shadowNoNo

Select boxes (single line)

See the <select><optgroup> and  <option> elements.

PropertyNTNote
CSS box model
widthPartial[1]Partial[1]
  1. This property is okay on the <select> element, but it cannot be the case on the <option> or <optgroup> elements.
heightNoYes
borderPartialYes
marginYesYes
paddingNo[1]Partial[2]
  1. The property is applied, but in an inconsistent way between browsers on Mac OSX.
  2. The property is well applied on the <select> element, but is inconsistently handled on <option> and <optgroup> elements.
Text and font
colorPartial[1]Partial[1]
  1. On Mac OSX, WebKit based browsers do not support this property on native widgets and they, along with Opera, do not support it at all on <option> and <optgroup> elements.
fontPartial[1]Partial[1]
  1. On Mac OSX, WebKit based browsers do not support this property on native widgets and they, along with Opera, do not support it at all on <option> and <optgroup> elements.
letter-spacingPartial[1]Partial[1]
  1. IE9 does not support this property on <select>, <option>, and <optgroup> elements; WebKit based browsers on Mac OSX do not support this property on <option> and <optgroup> elements.
text-alignNo[1]No[1]
  1. IE9 on Windows 7 and WebKit based browsers on Mac OSX do not support this property on this widget.
text-decorationPartial[1]Partial[1]
  1. Only Firefox provides full support for this property. Opera does not support this property at all and other browsers only support it on the <select> element.
text-indentPartial[1][2]Partial[1][2]
  1. Most of the browsers only support this property on the <select> element.
  2. IE9 does not support this property.
text-overflowNoNo
text-shadowPartial[1][2]Partial[1][2]
  1. Most of the browsers only support this property on the <select> element.
  2. IE9 does not support this property.
text-transformPartial[1]Partial[1]
  1. Most of the browsers only support this property on the <select> element.
Border and background
backgroundPartial[1]Partial[1]
  1. Most of the browsers only support this property on the <select> element.
border-radiusPartial[1]Partial[1]
box-shadowNoPartial[1]

Note Firefox does not provide any way to change the down arrow on the <select> element.

Select boxes (multiline)

See the <select>, <optgroup> and  <option> elements and the size attribute.

PropertyNTNote
CSS box model
widthYesYes
heightYesYes
borderYesYes
marginYesYes
paddingPartial[1]Partial[1]
  1. Opera does not support padding-top and padding-bottom on the <select> element.
Text and font
colorYesYes
fontYesYesSee the note about line-height.
letter-spacingPartial[1]Partial[1]
  1. IE9 does not support this property on <select>, <option>, and <optgroup> elements; WebKit based browsers on Mac OSX do not support this property on <option> and <optgroup> elements.
text-alignNo[1]No[1]
  1. IE9 on Windows 7 and WebKit based browser on Mac OSX do not support this property on this widget.
text-decorationNo[1]No[1]
  1. Only supported by Firefox and IE9+.
text-indentNoNo
text-overflowNoNo
text-shadowNoNo
text-transformPartial[1]Partial[1]
  1. Most of the browsers only support this property on the <select> element.
Border and background
backgroundYesYes
border-radiusYes[1]Yes[1]
  1. On Opera the border-radius property is applied only if an explicit border is set.
box-shadowNoPartial[1]
  1. IE9 does not support this property.

Datalist

See the <datalist> and <input> elements and the list attribute.

PropertyNTNote
CSS box model
widthNoNo
heightNoNo
borderNoNo
marginNoNo
paddingNoNo
Text and font
colorNoNo
fontNoNo
letter-spacingNoNo
text-alignNoNo
text-decorationNoNo
text-indentNoNo
text-overflowNoNo
text-shadowNoNo
text-transformNoNo
Border and background
backgroundNoNo
border-radiusNoNo
box-shadowNoNo

File picker

See the file input type.

PropertyNTNote
CSS box model
widthNoNo
heightNoNo
borderNoNo
marginYesYes
paddingNoNo
Text and font
colorYesYes
fontNo[1]No[1]
  1. Supported, but there is too much inconsistency between browsers to be reliable.
letter-spacingPartial[1]Partial[1]
  1. Many browsers apply this property to the select button.
text-alignNoNo
text-decorationNoNo
text-indentPartial[1]Partial[1]
  1. It acts more or less like an extra left margin outside the widget.
text-overflowNoNo
text-shadowNoNo
text-transformNoNo
Border and background
backgroundNo[1]No[1]
  1. Supported, but there is too much inconsistency between browsers to be reliable.
border-radiusNoNo
box-shadowNoPartial[1]
  1. IE9 does not support this property.

Date pickers

See the date and time input types. Many properties are supported, but there is too much inconstency between browsers to be reliable.

PropertyNTNote
CSS box model
widthNoNo
heightNoNo
borderNoNo
marginYesYes
paddingNoNo
Text and font
colorNoNo
fontNoNo
letter-spacingNoNo
text-alignNoNo
text-decorationNoNo
text-indentNoNo
text-overflowNoNo
text-shadowNoNo
text-transformNoNo
Border and background
backgroundNoNo
border-radiusNoNo
box-shadowNoNo

Color pickers

See the color input type:

PropertyNTNote
CSS box model
widthYesYes
heightNo[1]Yes
  1. Opera handles this like a select widget with the same restriction.
borderYesYes
marginYesYes
paddingNo[1]Yes
  1. Opera handles this like a select widget with the same restriction.
Text and font
colorN.A.N.A.
fontN.A.N.A.
letter-spacingN.A.N.A.
text-alignN.A.N.A.
text-decorationN.A.N.A.
text-indentN.A.N.A.
text-overflowN.A.N.A.
text-shadowN.A.N.A.
text-transformN.A.N.A.
Border and background
backgroundNo[1]No[1]
  1. Supported, but there is too much inconsistency between browsers to be reliable.
border-radiusNo[1]No[1]
box-shadowNo[1]No[1]

Meters and progress

See the <meter> and <progress> elements:

PropertyNTNote
CSS box model
widthYesYes
heightYesYes
borderPartialYes
marginYesYes
paddingYesPartial[1]
  1. Chrome hides the <progress> and <meter> element when the padding property is applied on a tweaked element.
Text and font
colorN.A.N.A.
fontN.A.N.A.
letter-spacingN.A.N.A.
text-alignN.A.N.A.
text-decorationN.A.N.A.
text-indentN.A.N.A.
text-overflowN.A.N.A.
text-shadowN.A.N.A.
text-transformN.A.N.A.
Border and background
backgroundNo[1]No[1]
  1. Supported, but there is too much inconsistency between browsers to be reliable.
border-radiusNo[1]No[1]
box-shadowNo[1]No[1]

Range

See the range input type. There is no standard way to change the style of the range grip and Opera has no way to tweak the default rendering of the range widget.

PropertyNTNote
CSS box model
widthYesYes
heightPartial[1]Partial[1]
  1. Chrome and Opera add some extra space around the widget, whereas Opera on Windows 7 stretches the range grip.
borderNoYes
marginYesYes
paddingPartial[1]Yes
  1. The padding is applied, but has no visual effect.
Text and font
colorN.A.N.A.
fontN.A.N.A.
letter-spacingN.A.N.A.
text-alignN.A.N.A.
text-decorationN.A.N.A.
text-indentN.A.N.A.
text-overflowN.A.N.A.
text-shadowN.A.N.A.
text-transformN.A.N.A.
Border and background
backgroundNo[1]No[1]
  1. Supported, but there is too much inconsistency between browsers to be reliable.
border-radiusNo[1]No[1]
box-shadowNo[1]No[1]

Image buttons

See the image input type:

PropertyNTNote
CSS box model
widthYesYes
heightYesYes
borderYesYes
marginYesYes
paddingYesYes
Text and font
colorN.A.N.A.
fontN.A.N.A.
letter-spacingN.A.N.A.
text-alignN.A.N.A.
text-decorationN.A.N.A.
text-indentN.A.N.A.
text-overflowN.A.N.A.
text-shadowN.A.N.A.
text-transformN.A.N.A.
Border and background
backgroundYesYes
border-radiusPartial[1]Partial[1]
  1. IE9 does not support this property.
box-shadowPartial[1]Partial[1]
  1. IE9 does not support this property.

See also

Learning path

Advanced Topics

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:179 次

字数:108883

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文