对 HTML 属性使用单引号是否正确? [英] Is it correct to use single quotes for HTML attributes?

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

问题描述

最近我看到了很多这样的:

Recently I've been seeing a lot of this:

<a href='http://widget-site-example.com/example.html'>
    <img src='http://widget-site-example.com/ross.jpg' alt='Ross&#39;s Widget' />
</a>

在 HTML 中使用单引号是否有效?正如我在上面强调的那样,它也存在问题,因为您必须避开撇号.

Is it valid to use single quotes in HTML? As I've highlighted above it's also problematic because you have to escape apostrophes.

推荐答案

使用单引号当然是有效的 (HTML 4.01,第 3.2.2 节).我没有注意到这种趋势,但也许有一些框架可以为您访问过的网站提供支持,这些网站恰好使用单引号进行引用.

It's certainly valid to use single quotes (HTML 4.01, section 3.2.2). I haven't noticed such a trend, but perhaps there's some framework that powers web sites you've visited that happens to quote using single quotes.

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

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