标签: html-head

为什么 <head> 中有“这不是零长度文件”

当我检查网页(甚至是 stackoverflow)时,我总是看到

<style type="text/css">/* This is not a zero-length file! */</style>
<style type="text/css">/* This is not a zero-length file! */</style>
Run Code Online (Sandbox Code Playgroud)

(是的,两次)在<head>标签的底部。

谷歌对此没有给出任何答案......

它来自Chrome吗?重点是什么?

编辑

感谢其他人的回答。此代码由Instant Translate Chrome 扩展程序生成。

css google-chrome html-head

5
推荐指数
1
解决办法
1256
查看次数

html头中拾取的元标记的顺序

我想知道是否有人可以解释社交媒体丰富的预览如何定义选择哪个og:title

我使用wordpress,对于某些页面,我会插入php echo字符串以将它们注入<head>。我选择这样做是为了将某些标题和说明更改为更多的商业文本。显而易见的是,有2个og:titlemeta标签;我注入了一个和Wordpress后端页面标题。

有人告诉我,顶部的第一个meta标签<head>将被选作meta标签,例如将其用于丰富的预览,但这似乎不再发生了。

以下是我目前的情况以及在中的元标记的确切顺序<head>

<html>
	<head>
		<meta charset="UTF-8">
		<title>EXAMPLE</title> // my injected and used by Google
		<link rel="canonical" content="https://example.com">
		<meta name="description" content="description">
		<meta name="subject" content="example">
		<meta name="og:image" content="/image.jpg"> // my injected and used by Social Media
		<meta property="og:title" content="og:title #1"> // my injected og:title, but ignored
		<meta property="og:description" content="description">
		<meta property="og:url" content="https://example.com">
		<meta name="twitter:title" content="EXAMPLE">
		<meta name="twitter:description" content="description">
		<link rel="alternate" href="https://example.com" hreflang="nl-nl">
		<link rel="alternate" href="https://example.com" hreflang="nl-be">
		<title>EXAMPLE</title> // default …
Run Code Online (Sandbox Code Playgroud)

html wordpress html-head meta-tags

5
推荐指数
0
解决办法
96
查看次数

从<head>中删除动态添加的css

点击按钮,我正在添加一个CSS <head>:

$("head").append("<link id='#color_1_css' href='" + newCssHref +"' type='text/css' rel='stylesheet' />");
Run Code Online (Sandbox Code Playgroud)

这增加了<head>:

<link id="#color_1_css" rel="stylesheet" type="text/css" href="http://domain.com/styles/colors/f69548/f69548.css">
Run Code Online (Sandbox Code Playgroud)

在另一个按钮单击我需要再次删除它.我尝试了以下内容,但由于某种原因无效:

   $('html').on('click', '.clear-color-picker', function(events){
           var id = $(this).attr('data-parentID').replace('background_color','');
           $('#' + $(this).attr('data-parentID')).setColor('');
           $('#' + id).css('background-color','');

           if (id == 'main-color') {
                console.log('clicked');
                $('#color_1_css').remove();
            }
   })
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

html css jquery html-head

3
推荐指数
1
解决办法
441
查看次数

在网页头部添加链接和元标记的顺序会产生负面影响吗?

我已将此代码添加到带有 .php 扩展名的网页中

<?php include_once("cssheadertop.php")?>
<link rel="stylesheet" href="button.css">
<?php include_once("cssheaderbottom.php")?>
Run Code Online (Sandbox Code Playgroud)

现在,cssheadertop.php 包含以下代码

<head>
<meta charset="utf-8">
<title>8mags - CSS Lessons</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="../../bootstrap.min.css" media="screen">
<link rel="stylesheet" href="../../style.css">
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Coda' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
Run Code Online (Sandbox Code Playgroud)

cssheaderbottom.php 文件有以下代码

  <style>
  page specific style here.
  </style>
  </head>
Run Code Online (Sandbox Code Playgroud)

我想在中间添加元描述和元关键字标签

 <?php include_once("cssheadertop.php")?> 
Run Code Online (Sandbox Code Playgroud)

 <?php include_once("cssheaderbottom.php")?>
Run Code Online (Sandbox Code Playgroud)

就像我添加的链接标签一样。

它会在渲染或 SEO 中造成任何问题吗?

html php meta html-head meta-tags

3
推荐指数
1
解决办法
1559
查看次数

如何使用YQL检索html文档的头部?

我很好奇这是否可行,因为"select*from html"查询只返回文档的正文.

yql html-head

2
推荐指数
1
解决办法
680
查看次数

将 DIV 放置在 &lt;head&gt; 中

我将在网站中安装一个横幅,其目标是整个网站的运行。横幅设置为position:fixed& bottom:0px,因此它将是底部的浮动横幅。

我的网站结构是一个公共的头文件,有很多对应不同页面的正文文件。

如果我把这个DIV放在公共头文件(该<head>部分)中,它会自动实现结果。但是,如果我把这个DIV放在body文件中(该<body>部分),我就必须一张一张地打开body文档并多次添加DIV。

我在网上看到,人们总是不建议在<head>节中放置DIV。我可以知道原因吗?有什么坏处吗?我自己测试了一下,好像没有太大区别。

html html-head

2
推荐指数
1
解决办法
1万
查看次数

链接到Document HEAD中的外部脚本的最佳方式

我注意到很多网站使用它,没有关闭标签.

 <script type="text/javascript" src="editor.js">
Run Code Online (Sandbox Code Playgroud)

这种风格也是推荐的,但更长:

 <script type="text/javascript" src="editor.js"></script>
Run Code Online (Sandbox Code Playgroud)

我可以这样写吗?它有效还是有更好的方法?

 <script type="text/javascript" src="editor.js" />
Run Code Online (Sandbox Code Playgroud)

javascript external-script html-head

0
推荐指数
1
解决办法
174
查看次数