Outlines, Border Styling, and Columns
Outlines
- An outline is a box drawn around an element, rendering outside of the border.
- What makes the outline unique is that it does not take up any height or width in the layout, so outlines for adjacent elements can overlap. This is different than the
borderproperty, which takes up space when rendered. - Think of outlines as being overlaid on top of the element.
- Outlines are best used for temporary visual effects, such as
:hoveror:focusstyling. - Thorough testing is recommended to ensure all target browsers are rendering as desired.
| Property | Usage and Effect | Values | Notes |
|---|---|---|---|
| outline-color | Determines the color of the outline. |
|
Only one color can be specified and it applies to all four sides. |
| outline-style | Determines the style of the outline. |
|
Only one style can be specified and it applies to all four sides. |
| outline-width | Determines the width of the outline. |
|
Only one width can be specified and it applies to all four sides. |
| outline | Combines the other outline-related properties into one sequence. | outline-width outline-style outline-color | Recommended because it is more efficient. |
| outline-offset | Moves the outline so that it is away from the element's edges. |
|
outline Example
See the Pen Outline by Jason Withrow (@jwithrow) on CodePen.
outline-offset Example
See the Pen Outline Offset by Jason Withrow (@jwithrow) on CodePen.
Border Styling
- The CSS Box Model has a variety of border-related properties, but as time passed more properties were added.
- This section explores those additions.
border-radius Example
| Property | Usage and Effect | Values | Notes |
|---|---|---|---|
| border-image | This shorthand allows images to be used for borders. |
|
See the border-image specification for the individual properties rolled into this shorthand. |
| border-radius | This shorthand allows borders to be rounded. |
|
For a specific corner:
|
| box-shadow | Applies a shadow to the edges of an element. |
|
Be careful not to trigger horizontal scrollbars on elements that fill their parent and have shadows applied. The shadows take up space and will then exceed the available width. |
border-radius Example
See the Pen Border Radius by Jason Withrow (@jwithrow) on CodePen.
box-shadow Example
See the Pen Box Shadow by Jason Withrow (@jwithrow) on CodePen.
Multiple Columns
- These properties allow web page content to be easily laid out in columns, similar to a newspaper.
- Columns can either be set up by widths or by count.
- This can be a good choice if you have an ordered or unordered list and you want the list items to flow across multiple columns; you would style the parent element of the list items accordingly.
- Note that sometimes there can be rendering anomalies cross-browser as elements wrap to new columns and may end up split apart across the columns; the key is careful testing and then trouble-shooting.
| Property | Usage and Effect | Values | Notes |
|---|---|---|---|
| column-count | Specifies the number of columns. |
|
|
| column-width | Specifies the width of each column. |
|
Each column is the same width.
If a If font size increases then more columns are added; the height should not be exceeded. |
| column-gap | Specifies the gap (gutter) between each column. |
|
Each column has the same space between it. |
| column-rule | Shorthand for styling vertical rules (lines) between the columns. |
Space-separated sequence of values:
|
The shorthand combines these properties:
|
| columns | Shorthand for setting column-width and column-count. |
|
Column Properties Examples
See the Pen Columns by Jason Withrow (@jwithrow) on CodePen.