是否有任何HTML编码约定/样式/标准 [英] Are there any HTML coding conventions/style/standard

查看:145
本文介绍了是否有任何HTML编码约定/样式/标准的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的意思是命名id,名称,值等等。

I mean to name ids, names, values, etc?

推荐答案

虽然我不认为有一个,用于命名HTML元素的接受的命名约定,您可能会发现以下文章有帮助。从第二页开始的内容可能是最有帮助的。祝你好运!

While I don't think there is a single, accepted naming conventions for naming HTML elements, you might find the following article helpful. The content starting on page two is probably most helpful. Good luck!

语义的含义采取II:CSS中类和ID的命名约定

The Meaning of Semantics Take II: Naming Conventions for Class and ID in CSS

这里有几个好的段落,作者尝试访问:

Here are a few good paragraphs that summarize what the author is trying to get at:


设计者可能命名为列
division #leftnav。乍一看
这是合乎逻辑的,在
的上下文中较小的网站,由一个或
维护只是几个人,真的没有
a很多问题

A designer might name a column division #leftnav. At first glance this is logical, and in the context of smaller sites, maintained by one or just a few folks, there really aren't a lot of problems with this kind of naming.

然而,考虑一个网站的大小
AOL或雅虎,大型团队的
设计师和开发人员每天管理
百万的页面。让我们
说从高的
到设计阶梯的设计决定是
将导航从
移到右边
它在$ b左侧的前家$ b屏幕。 CSS
的部分功能是在最佳情况下,切换导航的所有

require是进入CSS并通过重新定位交换
列它或
浮动它而不是左边。
保存该文件,然后百万
文档更新以反映
更改。

However, consider a site the size of AOL or Yahoo, on which large teams of designers and developers manage millions of pages every day. And let's say that a design decision from high on up the corporate ladder is made to move the navigation to the right from its former home on the left side of the screen. Part of the power of CSS is that in a best-case scenario, all that switching the navigation would require is to go into the CSS and swap the column by repositioning it or floating it right instead of left. Save that file and then millions of documents are updated to reflect the change.

但现在,数百万的文档也
有一个ID为#leftnav
的div,描述出现在
右边的列!没有做大量的
搜索和替换来更改(X)HTML中的ID
名称,文档是
现在对任何查看
源的人都很混乱,或者

But now, millions of documents also have a division with an ID of #leftnav describing a column that appears on the right! Without doing a massive search and replace to change the ID name in the (X)HTML, the document is now very confusing to anyone who views source, or (more importantly) comes in to work on the site.

这是为什么要避免演示和
选择更相关的描述
as simple因为#nav或#subnav将
在那种
环境中更有用。所以,即使它看起来
有点nitpicky,对于非常大的网站
我们想尝试和维护CSS的力量
和我们的
文档的纯度。智能类和ID名称
是该目标的主要部分。

This is why avoiding presentation and choosing a more relevant description as simple as #nav or #subnav will be more useful in that kind of environment. So, even if it might seem a bit nitpicky, for very large sites we want to try and maintain the power of CSS and the purity of our documents. Smart class and ID names are a major part of that goal.

这篇关于是否有任何HTML编码约定/样式/标准的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆