本文介绍了清空有效与否?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 根据规格 ( http://www.w3.org/TR/html401/struct/links.html#h-12.2) ,< a>元素 需要一个结束标记。因此,当我们使用< A NAME =" foo">在HTML 2.0中 4.01,它不会验证,它会想要找到< / A>标签。 然而,当我写一个文件,其中包含< a name =" foo" />它会在XHTML 1.0中验证。 我在这里显然遗漏了一些东西,因为这让我感到困惑。 神奇/使空元素有效吗?并且这不违反 http:// www。 w3.org/TR/xhtml1/#C_3 ? 最近我能算出来,它建议虽然标签会是 验证,我们仍然不应该这样做,以防UA无法处理空的 元素。我是在正确的轨道上吗? 如果没有,请随时纠正我。According to the specs(http://www.w3.org/TR/html401/struct/links.html#h-12.2), the <a> elementrequires an end tag. And so, when we use <A NAME="foo"> in HTML 2.0 to4.01, it won''t validate, it''ll want to find the </A> tag.However, when I write a document containing, say, <a name="foo" /> itvalidates in XHTML 1.0.I''m obviously missing something here, as this confuses me somewhat. Doesthe magical / make the empty a element valid? And doesn''t this violate http://www.w3.org/TR/xhtml1/#C_3 ?Nearest I can figure, it''s recommending that although the tag willvalidate, we still shouldn''t do it in case a UA can''t handle an empty aelement. Am I on the right track?If not, feel free to correct me.推荐答案 考虑完全放弃愚蠢的构造: < h3 id =" s5" ;>第5节< / h3> - SpartanicusConsider dropping the silly construct completely:<h3 id="s5">Section 5</h3>--Spartanicus 在HTML 2.0到4.01中,你必须写< a ...> ...< / a>"。 在XHTML中,你也可以写< a ... />。 规则是不同的。在XHTML中,这样添加了/。在 开始标记的末尾关闭元素。这在旧版HTML中是未知的。 写作"< a ... />"然而,在旧的用户代理中可能不会很好用 对XHTML一无所知。 请查看XHTML 1.0的规范。 /> - Bertilo Wennergren< be ****** @ gmx.net> < http://www.bertilow.com>In HTML 2.0 to 4.01 you must write "<a ...>...</a>".In XHTML you can also write "<a ... />".The rules are different. In XHTML such an added "/" at the end of astart tag closes the element. That is unknown in older HTML.Writing "<a ... />" might however not work well in old user agents thatdon''t know anything about XHTML.Do look up the specification for XHTML 1.0.--Bertilo Wennergren <be******@gmx.net> <http://www.bertilow.com> 如果您需要或希望让您的文档处于工作状态,这并不傻。 Netscape 4也是如此。糟糕的浏览器不会跳转到由id 属性定义的锚点,它需要< a name>。我个人正在转向新文件中的id属性 ,但有些犹豫。 - Yucca, http://www.cs.tut.fi/~jkorpela/ 关于网页创作的网页: http://www.cs.tut.fi/~jkorpela/www.htmlIt''s not silly if you need or wish to have your document working onNetscape 4 too. The poor browser does not jump to anchors defined by idattributes, it needs <a name>. Personally I''m moving to id attributesin new documents, mostly, but with some hesitation.--Yucca, http://www.cs.tut.fi/~jkorpela/Pages about Web authoring: http://www.cs.tut.fi/~jkorpela/www.html 这篇关于清空有效与否?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-20 11:59