SO #20992387: feature detection example

How to use feature detection to tell if display: table-row is supported.

HTML

<span id="row">
    <span>Cell 1</span>
    <span>Cell 2</span>
</span>

CSS

#row {
    border: 5px solid #0c0;
    padding: 5px 10px;
}

#row span {
    border: 5px solid #00c;
    display: table-cell;
}

JavaScript

function isTableRowSupported() {
    try {
        var style = document.createElement("div").style;
        style.display = 'table-row';
        return style.display == 'table-row';
    } catch (e) {
        return false;
    }
}

var row = document.getElementById('row');

if (isTableRowSupported()) {
    row.style.display = 'table-row';
} else {
    row.style.display = 'block';
}