It is common to use object detection to discriminate between browser capabilities (See Quirksmode: Object Detection.
However, sometimes it is necessary to detect whether or not a browser understands a particular CSS style property, and it is not obvious how to do this.
You can’t test for the existence of the property directly but you can test for the data type of the value of the property. If the data type is anything but “undefined”, the property is understood by the browser.
The example below shows a couple of rows from an automatically generated table of items. Each row has a corresponding editable version which shows up when the “edit” button is clicked. The original, non-editable row is hidden at the same time the editable row is displayed. If “display=’block” is used to display the TR, Safari will render it as a TD. To correct this, “display=’table-row” must be used on browsers that understand it.
Continue reading