I used a CSS layout to design a web page, and found that my naming was a bit confusing. I named it exactly according to my own ideas. Although it has no impact, I don’t show the source file to others, but sometimes the studio and the team When we work together to complete a project, we run into trouble. It’s quite troublesome to modify one place. So it’s better to have a standard!
I saw a relevant reference online, and I also study other people’s work. Code, I found that such naming is widely used! I added my own experience, hoping it will be useful to people who read this article!
Naming convention
Commonly used CSS naming rules:
Head: header
content: content/container
tail: footer
navigation: nav
sidebar: sidebar
column: column
page peripheral control overall layout Width: wrapper
Left right center: left right center
Use all lowercase letters for naming. If multiple words are needed, use "-" to separate the words, such as user-list
Common codes Structure:
div: mainly used for layout, the structure of dividing pages
ul/ol: used for unordered/ordered lists
span: has no special meaning and can be used as an auxiliary for typesetting , such as
Example Source Code
Example Source Code
fieldset & legend: fildset is placed outside the form, and legend is used to describe the form content. For example:
Example Source Code [www.52css.com]
Example Source Code
Example Source Code
C #content
S #subcol
M #maincol
X #xcol
Example Source Code]
.red{color:red}
.important-news{color:red}
Obviously the meaning conveyed by the second one is more clear , so try not to use unclear meanings as your own custom names.