Best Practice for Naming the Id Attribute of Dom Elements

前端 未结 5 1451
半阙折子戏
半阙折子戏 2021-02-04 03:14

This is related to naming conventions for a DOM element\'s id attribute and I guess the name attribute as well. When it comes to JavaScript, from what I understand and have done

5条回答
  •  礼貌的吻别
    2021-02-04 03:44

    One of the HTML gurus at my last job actually recommended delimiting multi-word IDs with dashes

    
    

    I'm struggling to remember why - I don't have access to those internal standards documents anymore. I know that really doesn't answer your question about Pascal vs Camel casing, though.

    I'd personally advise against using HN - I find it to be a largely abhorrent practice. What happens if you need to change your checkbox array to a select element instead? Now the element's ID has false semantics baked-in. It's just not worth the hassle, IMO.

提交回复
热议问题