简体   繁体   English

HTML属性中的空格

[英]White spaces in HTML attributes

Some of my class attributes are generated by PHP, so sometimes there are extra whitespaces in HTML output, in example: 我的某些class属性是由PHP生成的,因此有时HTML输出中会有多余的空格,例如:

class=" hey  joe "

As we can see there are: - empty first char - two empty chars between hey and joe - empty last char 我们可以看到:-空的第一个字符- heyjoe之间的两个空字符-空的最后一个字符

May it cause some problems for browsers, web crawlers or other problems? 可能会导致浏览器,网络搜寻器出现其他问题或其他问题吗?

There is no problem with this. 这没有问题。 The class attribute accepts any number of classes separated by whitespaces. class属性接受由空格分隔的任意数量的类。 Trailing and leading whitespaces are not significant here. 尾随空格和前导空格在这里并不重要。

Please see White Space handling in attribute values and Attribute-Value Normalization for authoritative details. 有关权威性详细信息,请参阅属性值属性值规范化中的 空白处理

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM