Css specifications and css naming rules

Source: Internet
Author: User

Css specifications and css naming rules

I. CSS writing Sequence

1. position attributes (position, top, right, z-index, display, float, etc)
2. Size (width, height, padding, margin)
3. text series (font, line-height, letter-spacing, color-text-align, etc)
4. background (background, border, etc)
5. Others (animation, transition, etc)

Ii. CSS writing specifications
1. Use the CSS abbreviation attribute
Some CSS attributes can be abbreviated, such as padding, margin, and font. This simplifies the code and improves the user's reading experience.

2. Remove the "0" before the decimal point"

3. Short Name

Many users prefer to use the abbreviated class name, but only when you understand your name can it be abbreviated!

4.16 hexadecimal color code abbreviation

Some color codes can be abbreviated. We recommend that you use them to improve user experience.

5-character CSS selector naming rules

1). Long names or phrases can be named by a hyphen.

2) It is not recommended to use the underscore "_" to name the CSS selector. Why?

Press the shift key less when you enter the key. browser compatibility problems (for example, the _ tips selector name is invalid in IE6) the JavaScript variable name can be well distinguished (the JS variable name is "_")

6. Do not use the id at will

Id is unique in JS and cannot be used multiple times, but the class selector can be used repeatedly. In addition, the priority of id is higher than that of class, so id should be used as needed, it cannot be abused.

7. Add a status prefix for the selector

Sometimes you can add a status prefix to the selector to make the semantics clearer. For example, you can add a ". is-" prefix.

Iii. CSS naming rules)
Common CSS naming rules

Header: header
Content: content/container
End: footer
Navigation: nav
Sidebar: sidebar
Column: column
Page peripheral control overall Board Width: wrapper
Left right center
Logon entry: loginbar
Logo: logo
Advertisement: banner
Page subject: main
Hotspot: hot
News: news
Download: download
Subnavigation: subnav
Menu: menu
Sub menu: submenu
Search: search
Link: friendlink
Footer: footer
Copyright: copyright
Scroll: scroll
Content: content
Tags: tags
Article list: list
Message: msg
Tips: tips
Topic title: title
Join: joinus
Guide: guide
Service: service
Registration: regsiter
Status: status
Vote: vote
Partner: partner

Annotation Syntax:

/* Header */
Content Area
/* End Header */

Id:

1) Page Structure

Container: container
Header: header
Content: content/container
Page subject: main
Footer: footer
Navigation: nav
Sidebar: sidebar
Column: column
Page peripheral control overall Board Width: wrapper
Left right center

(2) Navigation

Navigation: nav
Main navigation: mainnav
Subnavigation: subnav
Top navigation: topnav
Side navigation: sidebar
Left Navigation: leftsidebar
Right navigation: rightsidebar
Menu: menu
Sub menu: submenu
Title: title
Abstract: summary

(3) Functions

Logo: logo
Advertisement: banner
Login: login
Logon entry: loginbar
Registration: register
Search: search
Functional Area: shop
Title: title
Join: joinus
Status: status
Button: btn
Scroll: scroll
Tab
Article list: list
Message: msg
Current: current
Tips: tips
Icon: icon
Note: note
Guide: guild
Service: service
Hotspot: hot
News: news
Download: download
Vote: vote
Partner: partner
Link
Copyright: copyright

Iv. Notes ::

1. All are in lower case;
2. Try to use English;
3. Do not add a hyphen (-) or underscore;
4. Try not to be abbreviated, except words that can be understood without looking at them.

V. CSS style sheet File naming

Main master.css
Module module.css
Basic shared base.css
Layout.css
Themes.css
Columns.css
Text font.css
Form forms.css
Patch mend.css
Print. c

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.