Log in

View Full Version : Border="0" html4 strict / alternatives for no border img



Girard Ibanez
05-13-2007, 03:44 PM
Been trying to figure this one out.

Is there a substitute code when using html4 strict for a border="0" img that will validate.

<a href="http://www.duralitebatteries.com"><img src="image_themes/duralite.gif" alt="Duralite Batteries" border"0" />

Thanks

thetestingsite
05-13-2007, 03:48 PM
You have to use CSS for this. An example would be:



img {
border: 0px;
}


That will take any border of all images. If you only wanted to do this with those images that are linked, then do something like this in the css:



.linked-img {
border: 0px;
}


Then on every image that is linked, place this:



<img src="test.gif" class="linked-img" alt="Alt Text">


Hope this helps.

mwinter
05-13-2007, 07:34 PM
If you only wanted to do this with those images that are linked, then do something like this in the css:



.linked-img {
border: 0px;
}


Then on every image that is linked, place this:



<img src="test.gif" class="linked-img" alt="Alt Text">


Using context would be far more sensible:



a:link img {
border: none;
}



<!-- Nothing special about the img element: -->
<a href="..."><img alt="..." src="..."></a>

Girard Ibanez
05-14-2007, 03:46 AM
Thanks that did the trick..

G.

Twey
05-14-2007, 05:02 PM
Although others have corrected this in their examples, nobody mentioned it: the / at the end of your <img> tag in your original example is invalid HTML without SHORTTAGS.

mwinter
05-14-2007, 05:31 PM
Although others have corrected this in their examples, nobody mentioned it: the / at the end of your <img> tag in your original example is invalid HTML without SHORTTAGS.

The SGML declaration for HTML (http://www.w3.org/TR/html4/sgml/sgmldecl.html) enables the SHORTTAG feature. The only invalid part of the OP's post is the missing equals symbol (=) between the attribute name and value, however, ignoring that, the snippet doesn't technically result in the parse tree that the OP intended.