为什么“破折号为小写” HTML类的标准? [英] Why is "lower-case with dashes" the standard for HTML classes?

查看:122
本文介绍了为什么“破折号为小写” HTML类的标准?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


可能存在重复:


就我个人而言,我使用破折号小写来格式化我的HTML类,这些日子似乎是标准。使用类似于骆驼案例的东西似乎更多地保留在我的眼中,但我意识到这只是我的意见。



我正在努力改善我工作场所的前端代码一致性,其中一部分将是编码准则。而不是仅仅说我们应该这样做,我非常希望听到这个共同趋势背后的一些有效理由。

因此,总而言之,对于HTML类的小写破折号趋势,有什么有效的技术原因?

解决方案

Just就像你在你自己的问题中提到的那样,但我意识到这只是我的看法



编码约定是: p>


  • 使代码更具可读性的指导原则(用于识别,变量命名的空间量......)
  • 在任何语言中都不是限制




  • 总之,这只是一种你不需要遵循的编码方式,但是如果你这样做,它对于其他人来说更具可读性。



    如果你遇到一组约定,这意味着很多人都同意这一套,并为自己采纳(有或没有)我修改=))



    有些语言对约定有些限制(比如类名必须以大写字母开头,..),这就是为什么每种语言都不同。

    Possible Duplicate:
    Why are dashes preferred for CSS selectors / HTML attributes?

    Personally I use "lower-case with dashes" to format my HTML classes, which seems to be the standard these days. Using something like camel case seems more reserved for JavaScript in my eyes, but I realise that's just my opinion.

    I'm trying to improve front-end code consistency at my workplace and part of that will be coding guidelines. Rather than just saying "we should do it this way" I'm keen to hear some valid reasons behind this common trend.

    So the question in summary, what are some valid technical reasons for the "lower-case with dashes" trend for HTML classes?

    解决方案

    Just like you mentioned in your own question but I realise that's just my opinion.

    Coding-conventions are:

    • guidelines for making code more readable (amount of spaces for identation, naming of variables, ..)
    • in no way a limit in your coding
    • different for every language

    In short, it's only a proposed way of coding which you don't need to follow but it's more readable for other people if you do.

    If you come across one set of conventions, it means a lot of people agree with that set and adopt it for themselves (with or without some modifications =) )

    Some languages restrict conventions a bit (like class names having to start with an uppercase letter, ..), that's why it's different for every language.

    这篇关于为什么“破折号为小写” HTML类的标准?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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