English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

CSS Basic Tutorial

CSS Box Model

CSS3Basic Tutorial

CSS Reference Manual

CSS @rule (RULES)

CSS Outline (Outline)

(outline) The outline line is a line drawn outside the edge of the element (such as buttons, active form fields, etc.) to make it stand out.

Outline (Outline) VS Border (Border)

The outline is usually used to highlight elements. The outline looks very similar to the border at first glance, but it is different in the following aspects:

  • The outline does not occupy space because they are always placed at the top of the element box, which may cause them to overlap with other elements on the page.

  • Unlike the border, the outline does not allow us to set different widths for each edge, nor can we set different colors and styles for each edge. The outline is the same in all aspects.

  • The outline has no effect on the surrounding elements except for overlapping.

  • Unlike the border, the outline does not change the size or position of the element.

  • The outline may not be rectangular.

If the value of a single outline property is ignored or not specified when setting the shorthand property outline, outline will use the default value of that property (if any).If the outline is placed on the element, it will occupy the same space on the web page as if there was no outline on the element.

but in the case-width Outline width property

but in the case-The width attribute specifies the width of the outline to be added to the element. Its value should be a CSS length (px, pt, em, etc.) or one of the allowed keywords, but percentages or negative values are not allowed. Just likeborder-widthproperty is the same.

p {
    but in the case-width: thick;
}
Test See‹/›

If the value of a single outline property is ignored or not specified when setting the shorthand property outline, outline will use the default value of that property (if any).If outline-If the width is missing or not specified, the default value (medium) will be used instead.

but in the case-style Outline style property

This outline-style attribute sets the style of the outline, such as: solid, dotted, etc.

This property can take one of the following values: none, hidden, dashed, dotted, double, groove, inset, outset, ridge, and solid. Just likeborder-outlinevalues are the same.

none: no outline is defined.

hidden: definition of a hidden outline.

dotted: definition of a dotted outline

dashed: definition of a dashed outline

solid: definition of a solid outline

double: definition of two outlines. The width of the two outlines is the same as the outline width value

groove: definition3D Groove outline. The effect depends on the outline color value

ridge: definition3D Ridge outline. The effect depends on the outline color value

inset: definition3D Inserting outline. The effect depends on the outline color value

outset: definition3D Starting outline. The effect depends on the outline color value

p {
    but in the case-style: double;
}
Test See‹/›

but in the case-color Outline color property

but in the case-The color attribute sets the outline color.

p {
    but in the case-style: solid;
    but in the case-color: #0000ff;
}
Test See‹/›

color: black;-You can also set outline

If the value of a single outline property is ignored or not specified when setting the shorthand property outline, outline will use the default value of that property (if any).but in the case-color as transparent.-color If used alone, this property will not take effect. Use outline

Style property first sets the outline.

Outline Shorthand Property-The CSS outline property is a shorthand property that sets one or more individual outline properties, outline-style, outline-width and outline

p {
    outline: 5color in a single rule.9px solid #32acd
}
Test See‹/›

;

If the value of a single outline property is ignored or not specified when setting the shorthand property outline, outline will use the default value of that property (if any).but in the case-px solid;), then the element'sNote: 5When setting the element's outline, if the attribute value is missing or not specified (for example outline:px solid;), then the element'scolor-The property will be used as the value outline

color.5In the following example, the outline will be a width of

p {
    px black solid:
    outline: 5color: black;
}
Test See‹/›

px solid;but in the case-outlinestyle-The default value of styleproperty is none. If the value is omitted, no outline will be displayed because outline

In the following example, there will be no outline:

p {
    outline: 5px #00ff00;
}
Test See‹/›

Warning: Internet Explorer 7and earlier versions do not support the outline property. IE8 Outline is supported only in<!DOCTYPE>This property is supported only when specified for the a element.

Remove the dashed line around the active link

The outline property is widely used to remove the dashed line around the active link.

a, a:acive, a:focus {
    outline: none; /* Works in Firefox, Chrome, IE8 and above */
}
Test See‹/›