douxian6086 2010-09-29 08:19
浏览 22
已采纳

搜索引擎和'&'字符

I am about to finish up my dynamic classifieds website (php) and have some problem with figuring out how to write the meta and title tags.

I have read mixed articles about the & sign, and how to use it in the title or meta tags properly.

What role does the document encoding have and does the DOCTYPE have anything to do with this also?

In my case, this is my document top:

<!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">

I wonder, should I write the and tags with an '&' or an '&amp;' instead?

Just as an example:

 <title>Dolce & Gabbana</title>
             or
 <title>Dolce &amp; Gabbana</title>

I can't use the word 'and' simply because it doesn't "look" as good.

Thanks

  • 写回答

4条回答 默认 最新

  • dongxuxian6930 2010-09-29 08:37
    关注

    In this case both &amp; and even just & are valid as the latter is followed by a whitespace and thus cannot be confused with a reference open delimiter.

    But the HTML 4 specification recommends to use &amp; to avoid ambiguity:

    Authors should use "&amp;" (ASCII decimal 38) instead of "&" to avoid confusion with the beginning of a character reference (entity reference open delimiter). Authors should also use "&amp;" in attribute values since character references are allowed within CDATA attribute values.

    See my answer on Do I really need to encode '&' as '&amp;'? for further information.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划