为什么将 html 标签的结束右尖括号放在新 html 标签的左尖括号旁边?
我看到一个使用这种类型的代码结构编写的黑客,其中结束标签右“尖括号”放置在新的左“尖括号”标签开头的开头,但我不记得为什么这样做或线程。我认为这是 Chris Coyier 的 CSS 技巧网站,但不确定。有人知道为什么有人会这样编写标记吗?此代码片段取自此处< /a>
<!DOCTYPE Html>
<Html
><Head
><Title
>Graduation Ceremony Summer 2022</Title
></Head
><Body
><H1
>Graduation</H1
><Section
><H1
>Ceremony</H1
><P
>Opening Procession</P
>
></Section
></Body
></Html>
I seen a hack written using this type of code structure where the ending tag right 'angle bracket' is placed at the beginning of a new left 'angle-bracket' tag opening, but I can't remember why it was done or the thread. I'm thinking it was Chris Coyier's CSS tips site, but not sure. Does anybody have any idea why someone would write markup this way? This code snippet taken from here
<!DOCTYPE Html>
<Html
><Head
><Title
>Graduation Ceremony Summer 2022</Title
></Head
><Body
><H1
>Graduation</H1
><Section
><H1
>Ceremony</H1
><P
>Opening Procession</P
>
></Section
></Body
></Html>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
某些浏览器以不同的方式处理标签之间的空格。这是防止空文本节点出现在 DOM 中的一种方法。将它们放在您的文档中不太可能会造成任何麻烦(取决于您的 CSS 规则)。
我想到的一种情况是图像的垂直对齐。某些浏览器将图像标签旁边的空白(空文本节点)视为真实文本节点。如果您将图像与文本对齐,则可能会将其与空文本节点而不是图像旁边的实际文本对齐。
就可读性而言,我看到的只是一堆皱巴巴的愤怒面孔 (
>_<
)。我更愿意拥有标准外观的 HTML,而不是感觉像>_<
。Some browsers treat the whitespace between tags differently. This would be one way to prevent empty text nodes from appearing all over in the DOM. It's unlikely that having them in your document would cause any trouble (depending on your CSS rules).
One situation that comes to mind is vertical-alignment of images. Some browsers treat the whitespace next to an image tag (an empty text node) as a real text node. If you're aligning your image to the text, it might be aligning it to the empty text node instead of the actual text next to the image.
In terms of readability, all I see is a bunch of scrunchy angry faces (
>_<
). I would much rather have standard-looking HTML and not feel like>_<
.