Naming things correctly in CSS will make your code easier to read and maintain. We’re trying to make things easier, and save ourselves time in the future with more maintainable code. Personally, I tend to use only hyphen delimeter class names for simple projects, and BEM for more involved user interfaces.īEM - Block Element Modifier is a methodology, that helps you to achieve reusable components and code sharing in the… Why Use Naming Conventions? There are only two hard problems in Computer Science: cache invalidation and naming things - Phil Karlton That’s basically how the BEM naming convention works. redBox Īgain, note the use of the double hyphens in the example above. The problem is that this form of naming isn’t well-suited to CSS.ĭo not do this. var redBox = document.getElementById('.') If you write a lot of JavaScript, then writing variables in camel case is common practice. you’ve been there before, haven’t you? Use Hyphen Delimited Strings Here are a few naming conventions that will save you a bit of stress and countless hours down the line. Poorly written CSS will quickly turn into a nightmare. However, as you write more CSS, you quickly see one big downside. In my experience, this comes as a result of not taking the time to learn CSS.ĬSS isn’t the prettiest ‘language,’ but it has successfully powered the styling of the web for over 20 years now. I have heard lots of developers say they hate CSS.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |