我即将完成我的动态分类网站 (php),但在弄清楚如何编写 meta 和标题标签时遇到了一些问题。
我阅读了关于 &
符号以及如何在 title 或 meta 标签 中正确使用它的混合文章。
文档编码有什么作用,DOCTYPE 也有什么关系吗?
就我而言,这是我的文档顶部:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
我想知道,我应该用 '&
' 还是 '&
来写 和 标签' 而不是?
举个例子:
<title>Dolce & Gabbana</title>
or
<title>Dolce & Gabbana</title>
我不能仅仅因为它“看起来”不好就使用'and'这个词。
谢谢
最佳答案
在这种情况下,&
甚至只是 &
都是有效的,因为后者后跟一个空格,因此不能与引用开放分隔符混淆。
但是HTML 4 specification recommends to use &
为避免歧义:
Authors should use "
&
" (ASCII decimal 38) instead of "&
" to avoid confusion with the beginning of a character reference (entity reference open delimiter). Authors should also use "&
" in attribute values since character references are allowed within CDATA attribute values.
参见 my answer on Do I really need to encode '&
' as '&
'?了解更多信息。
关于php - 搜索引擎和 '&' 字符,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3819839/