You don’t need any fallback if you have an explicit label for any input field, which is recommended for accessibility and usability.
It would be rather strange to rely on the assumption that a browser supports the audio
element if and only if it supports the placeholder
attribute. For example, IE 9 supports audio
but not placeholder
.
A more reasonable approach (to removing the label when placeholder
is supported, which is IMHO a non-problem) is to add a piece of JavaScript that checks whether placeholder
is recognized as an attribute and remove the label if it is. The risk with this is that a browser may recognize the attribute without actually supporting it. The safest way seems to be to create an input
element in JavaScript and check whether the object has the placeholder
property:
<table>
<tr id="row">
<td id="label">
<label for="username">Username:</label>
</td>
<td>
<input type="text" name="Username" placeholder="Username" id="username">
</td>
</tr>
</table>
<script>
if(!('placeholder' in document.createElement('input'))) {
document.getElementById('row').removeChild(document.getElementById('label'));
}
</script>