Few days ago i came to know about CSS outline property and i thought how it is different from border property. According to W3Schools “An outline is a line that is drawn around elements (outside the borders) to make the element ‘stand out’ “. W3C says outline differ from border in the following ways (ref: http://www.w3.org/TR/CSS2/ui.html): Outlines do not take up space. Outlines may be non-rectangular. Outlines do not take up space Yes outline do not take up space, but how something can be placed in a web page without taking any space? It is similar to place an element over another using z-index, so outline does not take up any space because it is places on the top an the element. The size of any element before putting outline is same as that of the size of that element after putting outline. So outline does not add any extra space and does not change the element’s size or postion.
While border takes extra space and is added to the outer part of an element.
Outlined Image
Bordered Image
Outlines may be non-rectangular: It does not mean that you can create rounded outlines. When we add outline to an element then when the text inside the outlined area wraps, the box is closed and then reopened in the new line.
But in case of border, the entire element is treated as a rectangular box which is split over several lines until it is closed.
It is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industry’s standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
Apart from the above two differences, one more difference is there between border and outline, which is:
Outlines can have offset
Outline has a property called offset, which allows the outline to be moved further inside or outside of the element. Both border and outline has been applied to the content below.
.element { border: 1px solid #7B7F00; outline: 1px solid #7B7F00; outline-offset: -10px; }
It is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using ‘Content here, content here’, making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for ‘lorem ipsum’ will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
Hope this will help you : )
Thanks