Table of Contents
INTRODUCTION
The outline-style property sets the style of the outline around an element. Outlines are lines drawn outside the element’s border edge, and they do not take up space (unlike borders).
Possible values
The outline-style property can be specified in the following types.
| Value | Description |
|---|---|
none |
No outline (default if not specified). |
solid |
A single solid line. |
dotted |
A series of dots. |
dashed |
A series of short dashes. |
double |
Two solid lines.The width of outline is the sum of the two lines and the space between them. |
groove |
3D grooved outline (looks carved). |
ridge |
3D ridged outline (looks raised). |
inset |
Looks like the element is embedded. |
outset |
Looks like the element is coming out of the page. |
auto |
Browser chooses the style (often for accessibility focus outlines). |
Examples
The following figures shows all the possible styles of the outline-style property can take. The width and color of outline had been specifically set to 9px and violet respectively to enable user to clearly see the various styles.
1. solid
2. dotted
3. dashed
4. double
5. groove
6. ridge
7. inset
8. outset
9. auto
Frequently Asked Questions (FAQ)
How do I prevent the padding property from changing width or height in CSS?
box-sizing: border-box;
By default, CSS uses box-sizing: content-box, which means: width and height only include the content. Padding and border are added outside of that, increasing the final size.
Using box-sizing: border-box; changes the box model so that: width and height include the content, padding, and border. The total size stays fixed, no matter how much padding or border you add.
Can We Define max-padding or min-padding in CSS?
CSS treats padding as a single-value property, not a size constraint like width or height. The CSS box model doesn’t allow setting limits on padding values directly.
What does padding:10px, 15px, 12px, 20px; mean?
It is same as
padding-top: 10px;
padding-right: 15px;
padding-bottom: 12px;
padding-left: 20px;
What units can be used for padding in CSS?
Absolute Length Units - px, pt, pc, in, cm, mm, Q
Relative Length Units - em, rem, ex, ch, lh, rlh
Viewport Units - vw, vh, vmin, vmax
Percentage Unit - %
What is the default padding in CSS?
Can I Add Background Color Only for Padding in CSS?
example:
<div class="outer">
<div class="inner">Text</div>
</div>
.outer {
padding: 20px;
background-color: lightblue;
}
.inner {
background-color: white; /* Covers the content area */
}