是否建议使用HTML或JavaScript的最大行长? [英] Is there a recommended maximum line length for HTML or JavaScript?

查看:36
本文介绍了是否建议使用HTML或JavaScript的最大行长?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大多数编程语言的大多数样式指南都建议最大行长,通常为80个字符.对于HTML和JavaScript(嵌入HTML中),这似乎不切实际.对于HTML/JavaScript的实际行长限制是否达成共识?还是一般由开发人员常识决定?

Most style guidelines for most programming languages recommend a maximum line length, typically 80 characters. This seems impractically short for HTML and JavaScript (when it is embedded in HTML). Is there a consensus on a practical line length limit for HTML/JavaScript? Or is it generally left up to the developer's common sense?

推荐答案

自从您提到JavaScript以来,这就是道格拉斯·克罗克福德(Douglas Crockford)在这个话题上不得不说:

Since you mention JavaScript, this is what Douglas Crockford has to say on the topic:

避免行长超过80个字符.当一条语句不能放在一行中时,可能需要中断它.将中断放在运算符之后,最好放在逗号之后.操作员后的休息减少了分号插入掩盖复制粘贴错误的可能性.下一行应缩进8个空格.

Avoid lines longer than 80 characters. When a statement will not fit on a single line, it may be necessary to break it. Place the break after an operator, ideally after a comma. A break after an operator decreases the likelihood that a copy-paste error will be masked by semicolon insertion. The next line should be indented 8 spaces.

来自: JavaScript编程语言的代码约定

这篇关于是否建议使用HTML或JavaScript的最大行长?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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