元素链接缺少必需的属性属性 [英] Element link is missing required attribute property

查看:99
本文介绍了元素链接缺少必需的属性属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 <!DOCTYPE html> 
...
< link rel ='stylesheet'id ='basecss-css'href ='http://www.someurl.com/modules/14ce1e21/peadig-eucookie.css'type ='text / css'media ='all'/>

为什么验证器( http://validator.w3.org/ )拒绝这个?什么属性是我不知道的必需?



错误:


错误行408,列142:元素链接缺少必需的属性
属性。 ... / modules / 14ce1e21 / peadig-eucookie.css'type ='text / css'
media ='all'/>元素链接的属性:全局属性href
crossorigin rel media hreflang type sizes另外,标题属性
在这个元素上有特殊的语义。



解决方案

@stevelove显然是实用的解决方案,但这是对为什么问题的理论答案:

尽管链接元素在旧的HTML规范中的 body 中无条件无效,HTML5具有更宽松的规则。根据HTML 5.1 Nightly(这或多或少是验证者试图跟上的), link 元素在文档正文中也是允许的(只要允许短语内容) itemprop 属性。这似乎使错误信息更加令人困惑。部分解释是验证器实际上是针对HTML5 + RDFa进行验证,而RDFa则定义了属性属性。问题仍然存在于验证器正在检查的特定RDFa定义中,因为定义还需要重新定义HTML的规则。



错误消息中的信息已过时无论如何。错误消息显然不会像验证器的基本功能一样快地更新。


<!DOCTYPE html>
...
<link rel='stylesheet' id='basecss-css' href='http://www.someurl.com/modules/14ce1e21/peadig-eucookie.css' type='text/css' media='all' />

Why is the validator (http://validator.w3.org/) rejecting this? What attribute is "required" that I am not aware of?

The error:

Error Line 408, Column 142: Element link is missing required attribute property. …/modules/14ce1e21/peadig-eucookie.css' type='text/css' media='all' /> Attributes for element link: Global attributes href crossorigin rel media hreflang type sizes Also, the title attribute has special semantics on this element.

解决方案

The advice from @stevelove is apparently the practical solution, but here’s a theoretical answer to the "why" question:

Although a link element is unconditionally invalid in body in older HTML specifications, HTML5 has more permissive rules. According to HTML 5.1 Nightly (which is more or less what the validator tries to keep up with), the link element is allowed in the document body, too (wherever phrasing content is allowed), provided that it has an itemprop attribute. This seems to make the error message even more puzzling. Part of the explanation is that the validator is actually validating against HTML5 + RDFa, and RDFa defines the property attribute. The problem still remains what specific RDFa definition the validator is checking against, since the definition would need to redefine rules for HTML, too.

The information in the error message is outdated, anyway. Error messages are apparently not updated as fast as the basic functionality of the validator.

这篇关于元素链接缺少必需的属性属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆