{"id":14079,"date":"2011-09-05T20:53:01","date_gmt":"2011-09-06T03:53:01","guid":{"rendered":"http:\/\/css-tricks.com\/?page_id=14079"},"modified":"2021-08-09T12:04:40","modified_gmt":"2021-08-09T19:04:40","slug":"outline","status":"publish","type":"page","link":"https:\/\/css-tricks.com\/almanac\/properties\/o\/outline\/","title":{"rendered":"outline"},"content":{"rendered":"\n

The outline<\/code> property in CSS draws a line around the outside of an element. It’s similar to border<\/a> except that:<\/p>\n\n\n\n

  1. It always goes around all the sides, you can’t specify particular sides<\/li>
  2. It’s not a part of the box model<\/a>, so it won’t affect the position of the element or adjacent elements (nice for debugging!)<\/li><\/ol>\n\n\n\n

    Other minor facts include that it doesn’t respect border-radius<\/a> (makes sense I suppose as it’s not a border) and that it isn’t always rectangular. If the outline goes around an inline element with different font-sizes, for instance, Opera will draw a staggered box around it all.<\/p>\n\n\n\n

    It is often used for accessibility reasons, to emphasize a link when tabbed to without affecting positioning and in a different way than hover.<\/p>\n\n\n\n

    a:focus {\n  outline: 1px dashed red;\n}<\/code><\/pre>\n\n\n

    Shorthand<\/h3>\n\n\n
    outline: [ <outline-width> || <outline-style> || <outline-color> ] | inherit<\/code><\/pre>\n\n\n\n

    It takes the same properties as border, but with “outline-” instead.<\/p>\n\n\n\n

    The above shorthand could have been written:<\/p>\n\n\n\n

    a:focus {\n  outline-width: 1px;\n  outline-style: dashed;\n  outline-color: red;\n}<\/code><\/pre>\n\n\n

    Notes<\/h3>\n\n\n