문제

I have a .asp page and I'm having problem showing the image when I place a DOCTYPE on top of the ASP page. If I delete the DOCTYPE on top then the image will show up. Can anyone please help me figure out how to show the image withour deleting the DOCTYPE on top? Please see coding below:

DOCTYPE:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

HTML:

<table cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td style="width:200px"><span id="ImgHeader"></span></td>
    </tr>
</table>

CSS:

#ImgHeader
{
    background-image:url(img/header.jpg);
    width:200px;
    height:35px;
}
도움이 되었습니까?

해결책

As <span> is an inline element, you cannot apply height to it.

You should change <span> into <div>, which is a block element.

<td style="width:200px"><div id="ImgHeader"></div></td>

or apply the CSS selector to <td> if applicable:

<td id="ImgHeader">&nbsp;</td>

Last, it's time to change to a modern HTML5 DOCTYPE:

<!DOCTYPE html>

Important: never remove the DOCTYPE.

p.s. if you are worried about old browser support of HTML5 DOCTYPE, read this. In short, old browser supports this DOCTYPE too (except NS6, which I believe nobody is using it)

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top