HTML中允许使用单引号吗? [英] Are single quotes allowed in HTML?

查看:376
本文介绍了HTML中允许使用单引号吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是在PHP中使用双引号的大用户,因此我可以插入变量而不是连接字符串。因此,当我生成HTML时,我经常使用单引号来设置标记字段。例如:

  $ html =< input type ='text'name ='address'value ='$ address' >中; 

现在这比我的可读性要好得多了

  $ html =< input type = \text \name = \add​​ress \value = \$ address \> ; 

  $ html ='< input type =textname =addressvalues ='。$ address。'>'; 

在简短搜索中,我听到有人说每个浏览器都无法识别HTML字段的单引号。因此,我想知道哪些浏览器会识别单引号HTML有问题?

//当HTML中的单引号变得如此受欢迎时?。 允许HTML中的属性使用单引号规范。我认为任何浏览器都不会理解它们。


I am a big time user of using double quotes in PHP so that I can interpolate variables rather than concatenating strings. As a result, when I am generating HTML I often use single quotes for setting tag fields. For example:

$html = "<input type='text' name='address' value='$address'>";

Now this is far more readable to me than either

$html = "<input type=\"text\" name=\"address\" value=\"$address\">";

or

$html = '<input type="text" name="address" values="' . $address . '">' ;

From brief searches I have heard people saying that single quotes for HTML fields is not recognized by EVERY browser. Thus I am wondering what browsers would have problems recognizing single quote HTML?

解决方案

This is similar to When did single quotes in HTML become so popular?. Single quotes around attributes in HTML are and always have been permitted by the specification. I don't think any browsers wouldn't understand them.

这篇关于HTML中允许使用单引号吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆