ASP:Image auto generates - style="border-width:0px;"

by Sumant 16. May 2008 23:17

I don't remember noticing this anytime earlier. An asp-image control always generates this style attribute - style="border-width:0px;" - automatically.

This can be irritating when you actually want to display border around an image and are controlling it from a stylesheet, because the image won't display any border as its width is being set to 0 pixel.

Important thing is, if you are explicitly setting border-width for the image control then it's not a problem. Problem arises only when you are playing with stylesheet, which is the most common method used.

There are various workarounds to this problem, the one that I prefer is to make use of "!important" declaration in CSS (read more about "!important" here). This is done by setting border-width explicitly in CSS and telling browser to not to override it.

CSS-Code: set an image's border width
 img { border-width:1px!important } 

or

CSS-Code: set an image's border style
 img {border:solid 1px black!important} 

 

Few other workarounds are discussed here.

 

Share   
Digg It!DZone It!StumbleUponTechnoratiRedditDel.icio.usNewsVineFurlBlinkList

Tags:

.NET | ASP.NET | Web Development

© 2008 Sumant Dubey

About this blog

Absolutely technical! The posts are about concepts, tricks, articles and links on technical subjects / problems which are not very obvious to understand / resolve. Purpose is to have this as the first-aid in the time of need.

Disclaimer

The opinions expressed on this website are my own personal opinions and do not represent my employer's view in anyway.