HTML元素属性之间的换行符? [英] Newlines between HTML element attributes?

查看:163
本文介绍了HTML元素属性之间的换行符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问候,



我正在做一些个人项目的模板工作,我正在努力将我的线条保留在80个字符以内。这对于HTML来说很难做到,尤其是在为动态内容添加代码时。有很多情况下,在元素本身和属性之间放置换行符会很有帮助。以下是一个例子:

< a href =http://example.com> foobar< / a> $ b

基本上,我希望能够做到这一点:

< a

href =http://example.com> foobar< / a>



没有任何不良影响。它似乎验证和Firefox不介意,但我想接近一个权威的答案。我试图在HTML规范中找到答案无济于事。谷歌也没有任何帮助,所以我想我会问有知识的人。



感谢您的任何见解。

解决方案

这是有效的。只要你自己不破坏属性。例如:

这是有效的:


> href =http://example.com

>

foobar

< / a>

这不是:


> e.com> foobar< / a>


Greetings,

I'm doing some template work on a personal project and I'm trying very hard to keep my lines under 80 characters wide. This is difficult to do with HTML, especially when adding code for dynamic content as well. There are a lot of cases where it would be helpful to put line breaks inside the elements themselves, between attributes. Here's an example:

<a href="http://example.com">foobar</a>

Basically, I want to be able to do this:

<a
href="http://example.com">foobar</a>

without any ill effect. It seems to validate and Firefox doesn't mind, but I'd like something approaching an authoritative answer. I've tried to find the answer in the HTML specs to no avail. Google is no help either, so I thought I'd ask the knowledgeable folk.

Thanks for any insight.

解决方案

This is valid. as far as you don't break the attributes themselves. For example:

This is valid:

<a
href="http://example.com"
>
foobar
</a>

This is not:

<a href="http://exampl
e.com">foobar</a>

这篇关于HTML元素属性之间的换行符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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