Makes the naming rules for XHTML elements more reasonable.

Source: Internet
Author: User

Makes the naming rules for XHTML elements more reasonable.

 

As for the naming rules in CSS (in fact, I think the naming rules for XHTML elements are more reasonable), many people have already said this, and there are also some insights. However, this kind of thing is also benevolent, and wise, as long as a team has a unified naming rule requirement, it should be said that it is a good naming rule without confusion in daily development and maintenance. For example, the following basic naming rule:

CSS naming rules

Outer cover

Wrap

Main navigation

Mainnav

Subnavigation

Subnav

Footer

Footer

Entire page

Content

Page eyebrow

Header

Commodity mark

Label

Question mark

Title

Top navigation

Topnav

Side navigation

Sidebar

Left Navigation

Leftsidebar

Right navigation

Rightsidebar

Flag

Logo

Standard Language

Banner

Sub-menu

Submenu

Container

Container

Content

Content

Current

Current

The problem is, what will happen to the naming of leftsidebar and rightsidebar with strong directionality in the future? What if left is not left, center or right? What if rightsidebar appears on the left? At this time, the naming seems a bit illogical. Someone often tells me, do you think this is meaningful? Redundant! There are actually several websites that use the same structure for two different la S. Most of them are revisions, and even the structures have changed during the revisions. Such considerations are totally redundant. Indeed, there are often such problems. Some websites will not change their style even before the next revision, but some websites, such as my blog, will go to pjblog's official blog, the same structure has completely different performances.

See the following code:

 

 

 

Content

 

 

Bar1

 

 

Bar2

 

 

 

How can we name them? Bar1 and bar2 can appear on both sides or on one side. It is not suitable whether right, left, or middle is used. So how can we better name it?

Here we provide an idea from adobe.com, which uses the parent element-column group-column, where the column uses non-practical characters, such as A, B, and C. For example, wrap-AB-A, which means that the element with the ID of Wrap contains two divs -- A and B. Now the operation is. Such a name is completely irrelevant to the element, and the meaning is clear. For example, the above name can be written:

 

 

 

Content

 

 

Bar1

 

 

Bar2

 

 

 

"Container_abc_a" indicates that there are three parallel elements in the container (their IDs are A, B, and C). Currently, they point to the first one, that is,. The advantage of doing so is that the name and page are separated from the layout. However, one disadvantage is that, the meanings of A, B, and C make the name a bit "messy" When nesting again, such as ID = "container_abc_a_abc_a". It is not clear when the layers are deep.

I personally feel that such a name is novel and worthy of reference. As I said at the beginning, "as long as a team has Uniform Naming rules, it should be a good naming rule without confusion in daily development and maintenance ".

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.