javascript W3C 验证器:元素头缺少子元素标题的必需实例

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/23387958/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-28 00:48:20  来源:igfitidea点击:

W3C validator : Element head is missing a required instance of child element title

javascripthtmltitlew3c-validation

提问by nitansh bareja

Hi am validating my HTML code through w3c validator. But it is showing an error Element head is missing a required instance of child element title.

嗨,我正在通过 w3c 验证器验证我的 HTML 代码。但它显示错误元素头缺少子元素标题的必需实例。

URL is http://nitansh.fwd.wf/article/travel/best-all-inclusive-resorts-for-romance/3189783/

网址是 http://nitansh.fwd.wf/article/travel/best-all-inclusive-resorts-for-romance/3189783/

while title is Present in the head of the html body

而标题存在于 html 正文的头部

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>      Best all-inclusive resorts for romance- NowU
</title>
<link rel="stylesheet" href="/static/css/styles.css">
<link rel="stylesheet" href="/static/css/video-js.css">
<link rel="stylesheet" href="/static/css/font-awesome.min.css">
<link rel="stylesheet" media="print" href="/static/css/print.css">
  <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
  <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
  <!--[if lt IE 9]>
 <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js">
 </script>
 <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js">
 </script>
 <![endif]-->
 <link rel="stylesheet" href="/static/css/socialsharing.css">
 <link rel="canonical" href="/article/travel/best-all-inclusive-resorts-for-romance/3189783/">




  <meta name="description" content="Whether for a honeymoon, anniversary, or private escape, these resorts fit the romantic bill.">
  <meta property="og:description" content="Whether for a honeymoon, anniversary, or private escape, these resorts fit the romantic bill.">


  <meta name="twitter:card" value="Whether for a honeymoon, anniversary, or private escape, these resorts fit the romantic bill.">



  <meta property="og:title" content="Best all-inclusive resorts for romance">


  <meta property="og:type" content="article">


  <meta property="og:url" content="http://nitansh.fwd.wf/article/travel/best-all-inclusive-resorts-for-romance/3189783/">


  <meta property="og:image" content="http://www.gannett-cdn.com/media/USATODAY/USATODAY/2013/06/18/1371593281000-Earlyne-s-luggage-1306181810_3_4.jpg"></head>

回答by Dale

Just for your information this is what the validator is seeing in your code

仅供参考,这就是验证器在您的代码中看到的内容

<head>
<script src="//cdn.optimizely.com/js/687271175.js"></script>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<meta charset="UTF-8">
</head>

You can see this by turning on the show source option in the validator. Maybe it's time to look into progressive enhancement?

您可以通过在验证器中打开显示源选项来查看这一点。也许是时候研究渐进增强了?

回答by unor

Same solution as in your other question:

与您的其他问题相同的解决方案:

You are injecting the titleelement with JavaScript, but the W3C validator does not execute JavaScript.

title使用 JavaScript注入元素,但 W3C 验证器不执行 JavaScript。