CSS outline-width property sets the thickness of an element's outline. An outline is a line that is drawn around an element, outside the border .

The source for this interactive example is stored in a GitHub repository. If you'd like to contribute to the interactive examples project, please clone https://github.com/mdn/interactive-examples and send us a pull request.

It is often more convenient to use the shorthand property outline when defining the appearance of an outline.

句法

/* Keyword values */
outline-width: thin;
outline-width: medium;
outline-width: thick;
/* <length> values */
outline-width: 1px;
outline-width: 0.1em;
/* Global values */
outline-width: inherit;
					

outline-width property is specified as any one of the values listed below.

<length>
The width of the outline specified as a <length> .
thin
Depends on the user agent. Typically equivalent to 1px in desktop browsers (including Firefox).
medium
Depends on the user agent. Typically equivalent to 3px in desktop browsers (including Firefox).
thick
Depends on the user agent. Typically equivalent to 5px in desktop browsers (including Firefox).

形式定义

初始值 medium
适用于 所有元素
继承 no
计算值 an absolute length; if the keyword none is specified, the computed value is 0
动画类型 a length

形式句法

<line-width>

where
<line-width> = <length> | thin | medium | thick

范例

Setting an element's outline width

HTML

<span id="thin">thin</span>
<span id="medium">medium</span>
<span id="thick">thick</span>
<span id="twopixels">2px</span>
<span id="oneex">1ex</span>
<span id="em">1.2em</span>
					

CSS

span {
  outline-style: solid;
  display: inline-block;
  margin: 20px;
}
#thin {
  outline-width: thin;
}
#medium {
  outline-width: medium;
}
#thick {
  outline-width: thick;
}
#twopixels {
  outline-width: 2px;
}
#oneex {
  outline-width: 1ex;
}
#em {
  outline-width: 1.2em;
}
					

结果

规范

规范 状态 注释
CSS Basic User Interface Module Level 3
The definition of 'outline-width' in that specification.
推荐 无变化。
CSS Level 2 (Revision 1)
The definition of 'outline-width' in that specification.
推荐 初始定义。

浏览器兼容性

The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
outline-width Chrome 完整支持 1 Edge 完整支持 12 Firefox 完整支持 1.5
完整支持 1.5
不支持 1 — 3.6 Prefixed
Prefixed Implemented with the vendor prefix: -moz-
IE 完整支持 8 Opera 完整支持 7 Safari 完整支持 1.2 WebView Android 完整支持 37 Chrome Android 完整支持 18 Firefox Android 完整支持 4 Opera Android 完整支持 14 Safari iOS 完整支持 1 Samsung Internet Android 完整支持 1.0

图例

完整支持

完整支持

要求使用供应商前缀或不同名称。

要求使用供应商前缀或不同名称。

元数据

  • 最后修改: