web标准中定义id与class有什么区别吗
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">
<head profile="http://www.w3.org/2000/08/w3c-synd/#">
<meta http-equiv="content-language" content="zh-cn" />
<meta http-equiv="content-type" content="text/html;charset=gb2312" />
<title>blueidea</title>
<style type="text/css">
/*<![CDATA[*/
#aa {
color:red
}
.aa {
color:blue
}
/*]]>*/
</style>
</head>
<body>
<div id="aa" class="aa">
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="zh" lang="zh">
<head profile="http://www.w3.org/2000/08/w3c-synd/#">
<meta http-equiv="content-language" content="zh-cn" />
<meta http-equiv="content-type" content="text/html;charset=gb2312" />
<title>blueidea</title>
<style type="text/css">
/*<![CDATA[*/
.a {
color:orange
}
.b {
background:#eee
}
.c {
border:1px solid red
}
/*]]>*/
</style>
</head>
<body>
<div class="a b c">aaaaaaaa</div>
</body>
</html>
一.
web标准中是不容许重复ID的,比如 div id="aa" 一个页面中不容许重复2次,而class 定义的是类,理论上可以无限重复的,这样需要多次引用的定义便可以使用他.
class还可以同时引用多个类,不同的类之间用空格隔开.
二.
属性的优先级问题,ID 的优先级要高于class,看上面的例子
三.
方便JS等客户端脚本,如果在页面中要对某个对象进行脚本操作,那么可以给他定义一个ID,否则只能利用遍历页面元素加上指定特定属性来找到它,这是相对浪费时间资源,远远不如一个ID来得简单.
web标准中定义id与class有什么区别吗的更多相关文章
- Web标准中用于改善Web应用程序性能的各种方法总结
提起Web应用程序中的性能改善,广大开发者们可能会想到JavaScript与DOM访问等基于各种既存技术的性能改善方法.最近,各种性能改善方法被汇总成为一个Web标准. 本文对Web标准中所包含的各种 ...
- 【转】Web标准中的常见问题
本文转自http://www.tracefact.net/Misc/Common-Problems-Of-Web-Standard.aspx 引言 大概在2004年的时候,Web标准的概念藉由一本名为 ...
- Tomcat web.xml中定义了文件扩展名到MIME类型的对应关系
Tomcat在返回静态资源时,会根据资源文件的扩展名产生对应的content-type头(也即MIME类型)添加到response header中. 在Tomcat的web.xml规定了扩展名及相应M ...
- web.xml中Filter,Listener,Servlet的区别
一.Servlet Servlet是基本的服务端程序,他来自接口Servlet,接口中有方法service.而Servlet的一个重要实现类,则是tomcat服务器的核心,那就是HttpServlet ...
- Web标准中xhtml规范的内容有哪些
1.所有的标记都必须要有一个相应的结束标记 以前在HTML中,你可以打开许多标签,例如<p>和<li>而不一定写对应的</p>和</li>来关闭它们.但 ...
- 为什么web标准中无法设置IE浏览器滚动条颜色了?
<!doctype html><html> <head> <meta charset="UTF-8"> <meta name= ...
- Web开发中 MTV模式与MVC模式的区别 联系 概念
MTV 与 MVC模式的区别 联系 概念: MTV: 所谓MTV指的就是: M:model (模型),指的是ORM模型. T:template (模板),一般Python都是使用模板渲染的方式来把HT ...
- HTML中属性ID和属性NAME的区别(转)
ID和Name都可以用来标识一个标记,Javascript分别有两个方法getElementById和getElementByName来定位Dom节点. 区别如下: 1.我们知道在网页做Post提交时 ...
- web标准常见问题整理
1.超链接访问过后hover样式就不出现的问题 2.FF下如何使连续长字段自动换行 3.ff下为什么父容器的高度不能自适应 4. IE6的双倍边距BUG 5. IE6下绝对定位的容器内文本无法正常选择 ...
随机推荐
- <每日一题>题目18:对象组合和对象构造面试题(深度优先和广度优先的问题)
class Node(object): def __init__(self,sName): self._lChildren = [] self.sName = sName def __repr__(s ...
- 2018-12-18-WPF-一个空的-WPF-程序有多少个窗口
title author date CreateTime categories WPF 一个空的 WPF 程序有多少个窗口 lindexi 2018-12-18 21:16:40 +0800 2018 ...
- Mybatis的插件 PageHelper 分页查询使用方法
参考:https://blog.csdn.net/ckc_666/article/details/79257028 Mybatis的一个插件,PageHelper,非常方便mybatis分页查询,国内 ...
- 05.Hibernate常用的接口和类---Configuration类和作用
Configuration作用: 加载Hibernate配置文件,可以获取SessionFactory对象 加载方式: 1.加载配置文件 Configuration configuration = n ...
- hdu6277
hdu6277结论题 #include<iostream> #include<cstdio> #include<queue> #include<algorit ...
- Django项目:CRM(客户关系管理系统)--79--69PerfectCRM实现CRM业务流程(bpm)学生讲师分页
# student_views.py # ————————60PerfectCRM实现CRM学生上课记录———————— from django.shortcuts import render #页面 ...
- webpack 处理图片文件
1. 安装 file-loader html-loader npm install file-loader html-loader --save-dev 其中html-loader生效需配合 html ...
- 矩阵快速幂2 3*n铺方格
#include <iostream> #include <cstdlib> #include <cstring> #include <queue> # ...
- MYSQL数据库练习题操作(select)大全
1.创建表 表一:student学生use) .create table student( sno ) primary key not null comment'学号(主码)', sname ) no ...
- docker启动redis设置密码
docker run --name picker-redis -p 6379:6379 -d redis --requirepass "认证密码"