CSS Reference

"outline" - css property (v. css 2)

  • At times, style sheet authors may want to create outlines around visual objects such as buttons, active form fields, image maps, etc., to make them stand out.
  • In contrast with border, outline will not take up space and may be non-rectangular.
  • This property is a shorthand property for setting 'outline-width' , 'outline-style' and 'outline-color' at the same place in the style sheet.
  • Initial value: See individual properties
  • The property is not inherited
  • HTML usage: All elements
  • Browsers that support the outline - property :
    Internet Explorer Mozilla Firefox Opera Google Chrome Apple Safari

Property "outline" example:

<!DOCTYPE HTML >
<html>
  <head>
    <style   type="text/css">
      .div1 { position: relative;
              height: 200px;
              width: 240px;
              outline: #0000FF 2px solid;}
      .p1 { position: relative;
            top: 10px;
            left: 10px;
            outline-color: inherit;
            outline-style:  inherit;
            outline-width:  inherit;
      }
    </style>
  </head>
  <body >
    <div class="div1">
      Some text in the DIV element
      <p class="p1" ><img width="170px" height="100px"
       src="images/ferrari.png" alt="A ferrari image">
      </p>
      The above P element inherits the
      outline of the DIV element
    </div>
  </body>
</html>

Javascript access:

// To SET values ([o] is the target object)
[o].style.outline="outline values"
// To GET values you must first get the computed style object
// To get that object in IE or Opera:
var cStyle=[o].currentStyle;
// To get that object in Firefox, Chrome or Safari (w3c-type):
var cStyle=window.getComputedStyle([o],null)
// To GET the property value:;
var value=cStyle.outline;
/* The returned value is not cross-browser reliable. The value can vary in accuracy and notation, which depends on the browser, whether the value is preset or not and which option that was used to set the value.*/
© 2010 by Finnesand Data. All rights reserved.
This site aims to provide FREE programming training and technics.
Finnesand Data as site owner gives no warranty for the correctness in the pages or source codes.
The risk of using this web-site pages or any program codes from this website is entirely at the individual user.