I need an image to resize to the full width of my webpage. This works fine with the following HTML/CSS:
#logo{
position: fixed;
top: 0;
left: 0;
min-width: 100%;
z-index: 3;
opacity: .8;
}
<div id="logo"><img src="/logo.png" alt="logo" width="100%"></div>
However W3C validation picks this up as an error. "Bad value 100% for attribute width on element img: Expected a digit but saw % instead."
I tried this alternative, but now the image does not resize of course:
<div id="logo"><img src="/logo.png" alt="logo" width:100%;></div>
How do I retain the same effect while still passing the W3C validation? It is the only error on my entire page, and I know it doesn't really matter, but there is bound to be a solution I am overlooking.
Kindly use the following code in order for you to have W3C validation
<div id="logo"><img src="/logo.png" alt="logo" width="100%" /></div>
(OR)
<div id="logo"><img src="/logo.png" alt="logo" style="width:100%;" /></div>
Because width attributes does not use % it uses digits like width='100'
, means 100px. if you want to apply 100% width on image, use CSS
#logo img {
width: 100%
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With