<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener('load', function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <div id="navbar-iframe-container"></div> <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script> <script type="text/javascript"> gapi.load("gapi.iframes:gapi.iframes.style.bubble", function() { if (gapi.iframes && gapi.iframes.getContext) { gapi.iframes.getContext().openChild({ url: 'https://www.blogger.com/navbar.g?targetBlogID\x3d8211560\x26blogName\x3dTech+Tips,+Tricks+%26+Trivia\x26publishMode\x3dPUBLISH_MODE_BLOGSPOT\x26navbarType\x3dBLUE\x26layoutType\x3dCLASSIC\x26searchRoot\x3dhttp://mvark.blogspot.com/search\x26blogLocale\x3den\x26v\x3d2\x26homepageUrl\x3dhttp://mvark.blogspot.com/\x26vt\x3d-5147029996388199615', where: document.getElementById("navbar-iframe-container"), id: "navbar-iframe" }); } }); </script>

Tech Tips, Tricks & Trivia

by 'Anil' Radhakrishna
An architect's notes, experiments, discoveries and annotated bookmarks.

Search from over a hundred HOW TO articles, Tips and Tricks


CSS Attribute selector input[type="checkbox"] works inconsistently

A web developer posted a question on the ASP.NET Forums wanting to know why a CSS style setting involving the attribute selector input[type="checkbox"] wouldn’t work.

As per the Quirksmode browser compatibility table, attribute selectors should work on popular browsers except on IE versions older than 7 but the selector input[type="checkbox"] seems to be an exception.

I created a test page by adapting a sample from W3Schools, adding a CSS attribute selector style setting to be applied to all checkboxes on a web page.



I found that the style  involving that attribute selector was applied only in IE version 7, 8 & Opera ( I tested in Opera 9.64). It failed in Safari, Firefox & Chrome.

While the style setting for input[type="text"] in the example appears correctly on all browsers, it was surprising that the style defined with the selector input[type="checkbox"] is not recognized by some browsers.

Also see:
HOW TO access a HTML Label tag's text programmatically
Conditional comments & CSS child selector
90

Labels:

Tweet this | Google+ it | Share on FB

« Home | Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »
| Next »

»

Post a Comment