一个或多个元标签?(One or multiple meta-tags?)
我刚刚意识到我的HTML
head
有两个meta
标记:<meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
当有多个时,两者都有效吗? 我应该合并吗? 拥有多个元标记是否同样出色?
I just realized I have two
meta
tags in my HTMLhead
:<meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0 user-scalable=no">
Do both work when there are multiple? Should I merge them? Is it just as good with having multiple meta-tags?
更新时间:2023-02-05 09:02
最满意答案
必须指定
name
,http-equiv
和charset
中的一个属性。因此,您的两个示例
meta
元素无法合并,因为meta
元素将具有charset
和name
属性,这是不允许的。Have a look at the definition of the
meta
element. It says:Exactly one of the
name
,http-equiv
, andcharset
, attributes must be specified.So your two example
meta
elements couldn’t possibly be merged, because then themeta
element would have thecharset
and thename
attribute, which is not allowed.
相关问答
更多-
我认为你应该逃避:看文档 $("meta[property='og\\:title']").attr("content", result.title); I think you should escape : look at the documentation $("meta[property='og\\:title']").attr("content", result.title);
-
Facebook刮板只能看到来自服务器的原始HTML响应中包含的标签。 运行任何JavaScript代码,Flash插件,Java小程序或其他任何可以运行的完整浏览器都不够“智能”。 您需要使用服务器端框架在服务器上生成这些标记。 此外,Facebook提供了一个方便的测试工具 ,以确保您的网页公开适当的元标记。 您可能还需要添加OpenGraph标记,例如og:title和og:description 。 The Facebook scraper can only see简单的答案是: viewport是好的,其他的...不太好。 视 viewport是一个广泛支持的事实标准 - 最初由苹果公司在iPhone上为移动Safari创建,几乎所有其他移动浏览器都采用了Opera Mobile,iPhone,Android,Iris,IE,BlackBerry,Obigo,Firefox 简单的示例用例:使网站的宽度在手机上: 另外两 ...不确定这是否是优化的方式,但这应该工作。 $("meta").each(function() { if($(this).attr("name") == "twitter:image") { $(this).attr("content" , "image/paragraphxi34343.jpg"); }; }); 一种更通用的方式 function changeMetaContent(metaName, newMetaContent) { $("meta").each(funct ...关于1: og:type应该是您的情况下的网站,我猜,而不是产品。 看到 https://developers.facebook.com/docs/reference/opengraph 关于2: 您需要为og:image属性传递绝对路径,而不是相对路径。 看到 https://developers.facebook.com/docs/opengraph/creating-custom-stories/#objecttypes-properties 关于3: 我认为这是由错误的og:type引起的 Conc ...HtmlAgilityPack的HtmlDocument实现了IXpathNavigable ,因此它使用标准的.NET XPath引擎。 任何XPath 1.0文档都将适用,特别是如果它谈及System.Xml.XPath。 “// comment()”查找所有评论 “// meta”查找所有“meta”元素 HtmlDocument的设计看起来非常像XmlDocument ,所以关于它的示例和教程将会有所适用。 一些MSDN链接: XPath参考 例子 XPath函数 HtmlAgilityPack's ...怎么样^(?:\s*\s*)+$ 请参阅: https : //regex101.com/r/iJ7fT8/2 How about ^(?:\s*\s*)+$ See: https://regex101.com/r/iJ7fT8/2我最终做了一个视图和一个来自umbraco的页面,它从控制器呈现视图。 它动态地添加了正确的元标记。 用户点击分享,就是这样,我只是为Facebook的抓取工具提供用户看不到的产品页面。 然后当有人点击Facebook上的共享网址时,它会重定向到我想要的网址。 之前尝试使用javascript和ajax,甚至改变控制器中的主模板标签,甚至检查facebook的爬虫是否在网站上,只有最后一个工作部分但是... I ended up doing a view and a page from umbraco on ...解决。 结果我需要重启我的rails服务器。 我通过搜索与'undefined gem methods'相关的东西来解决这个问题并得到了这个问题 - > 在Ruby On Rails中使用Gems:未定义的方法? Resolved. Turns out I needed to restart my rails server. I figured this out by searching things related to 'undefined gem methods' and got this quest ...
一个或多个元标签?(One or multiple meta-tags?)[2023-02-05]
看看meta元素的定义 。 它说: 必须指定name , http-equiv和charset中的一个属性。 因此,您的两个示例meta元素无法合并,因为meta元素将具有charset 和 name属性,这是不允许的。 Have a look at the definition of the meta element. It says: Exactly one of the name, http-equiv, and charset, attributes must be specified. So yo ...相关文章
更多- HTML meta标签
- Solr4:Tomcat7与Solr之多核配置(Multiple Cores)
- 关于微信公众号内嵌网页的几个meta标签
- HMTL 表单标签
- FreeMarker基本标签的使用
- Hadoop配置多个硬盘
- HMTL 图形标签(img标签)
- cms中标签的设计与实现
- Hadoop下运行多个SecondaryNameNode的配置
- HMTL 表格标签
最新问答
更多- 在javascript中创建类以创建对象并在Java中创建类和对象之间的区别(Difference between creating a class in javascript to create an object and creating an class and object in Java)
- Facebook API:将身份验证详细信息从Javascript SDK发送到PHP SDK(Facebook API: Send authentication detail from Javascript SDK to PHP SDK)
- 如何停止队列动画jquery?(How can I stop queue animation jquery?)
- 使用C#的井字游戏中的人工智能(Artificial Intelligence in Tic-Tac-Toe using C#)
- 多少流量可以共享虚拟主机(对于Python Django站点)支持?(How Much Traffic Can Shared Web Hosting (for a Python Django site) support?)
- 带有CIFilters的CAShapeLayer(CAShapeLayer with CIFilters)
- 如何在Angular 2中读取JSON #text(How to read in Angular 2 the JSON #text)
- 如何在xml中读取自闭标签的属性?(How to read self closing tag's attribute in xml?)
- 无法使用http put将图像上传到亚马逊S3(Cannot upload image to amazon s3 using http put)
- 文件结束无限循环(end of file infinite while-loop)
- 在cpp的模板(template in cpp)
- 在构建库时,clang和clang ++有什么区别?(What's the difference between clang and clang++ when building a library?)
- ng类中的表达式(expression inside ng-class)
- 在PHP中获取随机布尔值true / false(Get random boolean true/false in PHP)
- 管道的高效分块用于严格的字节串(Efficient chunking of conduit for strict bytestring)
- Python ternary_operator(如果其他标志做了其他操作,则执行其他操作)(Python ternary_operator (do-somthing if flag else do-another))
- Sencha Touch面具发布(Sencha Touch mask ondisclosure)
- 验证脚本上的通知[重复](Notices on validation script [duplicate])
- 朋友功能(friend function)
- 基于角坐标平移和变换平面几何(Translate and transform plane geometry based on corner coordinates)
- Rails:'如果在本地运行'条件javascript标记包括(Rails: 'if running locally' conditional javascript tag include)
- 解压文件(Unzipping files)
- 使用ui-router以角度加载变量状态(loading in variable states with ui-router in angular)
- 创建Azure云服务需要多长时间?(how long does it take to create an Azure Cloud Service? How to view log information?)
- 指向整数的指针数组(Array of pointers to integers)
- Laravel服务提供商没有看到我的包的主要类(Laravel service provider does not see the main class of my package)
- 这个关于VSS / RSS / PSS / USS的解释是否准确?(Is this explanation about VSS/RSS/PSS/USS accurate?)
- 在Django-Admin中通过row-id排序显示项目(Ordering the display items by row-id in Django-Admin)
- 如何使用cythonize启用`--embed`?(How to enable `--embed` with cythonize?)
- 用于将文本多行设置的Excel脚本(Excel script for ereasing text multiple rows)