Is it OK to write Javascript code to solve a browsers compatibility problem or I should never need that and everything should be solved using CSS only?
My problem:
I have a menu in an ASP.Net application, this menu renders a hidden image control supposing that height=0 and width=0 will not render anything. That’s true in IE but it keeps an empty area in Chrome and it looks ugly.
This is the generated code:
<img alt="Skip Navigation Links" src="/WebResource.axd?d=6z..."
width="0" height="0" style="border-width:0px;" />
I wrote the following code to solve the problem:
<script type="text/javascript">
$('img[height="0"]').css('display', 'none');
</script>
Is what I did true and the only way to solve such problems?
Note: The code in my example is generated for an ASP.Net menu control and I have no access on it to set a specific style
I don’t think javascript is nessessary in this case as you can either add a class or id to the element and set a style or use: