IE 8为img标签创建空文本节点

时间:2023-02-15 00:28:25

When i try to add a <img> tag, IE8 automatically add a 'Empty Text Node' after the image tag.

当我尝试添加IE 8为img标签创建空文本节点标签时,IE8会在图片标签后自动添加“空文本节点”。

HTML :-

<html>
<head>
    <title>Railway Services</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <link rel="shortcut icon" href="img/icon.png" />
    <link rel="stylesheet" href="css/styles.css" />
    <script type="text/javascript" src="js/jquery.min.js"></script>
    <script type="text/javascript" src="js/script.js"></script>
</head>
<body>
    <div id="header">
        <div id="wrapper">
            <div class="logo">
                <img src="img/logo.png"/>
            </div>
        </div>
    </div>
    <div id="page" class="homePage">
       <div id="wrapper">
          <h1>Home Page</h1>
       </div>
   </div>
   <div id="footer">
      <div id="wrapper">
            <p class="copyRight">Copyright&#169;2012 Railway Services. All rights reserved</p>
      </div>
    </div>
</body>
</html>

styles.css :-

@CHARSET "ISO-8859-1";
body{
   margin:0px;
   padding:0px;
   font-size:12px;
   color:#123456;
   font-family:verdana,_sans,arial;
   text-align:center;
}
#wrapper{
   width:98%;
   margin:0 auto;
}
#page{
   float:left;
   width:100%;
}
p{
   margin:0px;
   padding:0px;
}

/**********************HEADER*********************/

#header{
   float:left;
   width:100%;
}
.logo{
   float:left;
   width:20%;
   height:150px;
   cursor:pointer;
}
.logo img{
   width:100%;
   height:100%;
}

/************************HEADER END***************/

/************************FOOTER*******************/

#footer{
   float:left;
   width:100%;
}

/***********************FOOTER END****************/

See this image

看到这个图像

IE 8为img标签创建空文本节点

In the above image you can see the IE generates Empty Text Node after the <img> tag.

在上图中,您可以看到IE在IE 8为img标签创建空文本节点标记后生成空文本节点。

I can't found why IE generate empty text node.Can anybody help me..?

我无法找到为什么IE生成空文本节点。任何人都可以帮助我..?

2 个解决方案

#1


2  

There is a line break and some whitespace for indentation after the image tag, which leads to creating an empty text node.

在图像标记之后有一个换行符和一些用于缩进的空格,这导致创建一个空文本节点。

If you write your code like that:

如果您编写代码:

<div class="logo"><img src="img/logo.png"/></div>

you will not have the empty text node any more.

你将不再拥有空文本节点。

Since it's really IE specific, I think it's just a bug of the parser.

由于它确实是IE特定的,我认为它只是解析器的一个错误。

#2


3  

IE shows this to any elements in the page that has a blank space between tags. This may not cause any problem.

IE向页面中标签之间有空格的任何元素显示此信息。这可能不会导致任何问题。

The only consideration is when your content is inline and it adds a space between the elements. In this case, all you have to do is eliminate the blank space between the tags.

唯一的考虑因素是您的内容是内联的,并在元素之间添加空格。在这种情况下,您所要做的就是消除标签之间的空白。

#1


2  

There is a line break and some whitespace for indentation after the image tag, which leads to creating an empty text node.

在图像标记之后有一个换行符和一些用于缩进的空格,这导致创建一个空文本节点。

If you write your code like that:

如果您编写代码:

<div class="logo"><img src="img/logo.png"/></div>

you will not have the empty text node any more.

你将不再拥有空文本节点。

Since it's really IE specific, I think it's just a bug of the parser.

由于它确实是IE特定的,我认为它只是解析器的一个错误。

#2


3  

IE shows this to any elements in the page that has a blank space between tags. This may not cause any problem.

IE向页面中标签之间有空格的任何元素显示此信息。这可能不会导致任何问题。

The only consideration is when your content is inline and it adds a space between the elements. In this case, all you have to do is eliminate the blank space between the tags.

唯一的考虑因素是您的内容是内联的,并在元素之间添加空格。在这种情况下,您所要做的就是消除标签之间的空白。