HTML5保留的通用属性

id:元素唯一标识

<!DOCTYPE html>
<html>
<head>
	<meta name="author" content="Yeeku.H.Lee(CrazyIt.org)" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title> id属性 </title>

</head>
<body>
<div id="show" style="width:400px;height:120px;background-color:red;"></div>
<a href="#" onclick="change();">改变颜色</a>
<script type="text/javascript">
	var change = function()
	{
		var div = document.getElementById("show");  // ①
		div.style.backgroundColor = div.style.backgroundColor == 'red'?
			'green' : (div.style.backgroundColor == 'green'? 'blue': 'red');
	}
</script>
</body>
</html>

style:用于为HTML元素指定css样式;

class:用于匹配css样式的class选择器;

<html>
<head>
	<meta name="author" content="Yeeku.H.Lee(CrazyIt.org)" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title> class属性 </title>
	<style type="text/css">
		div.content {
			width: 300px;
			height: 120px;
			border: 1px solid black;
			float:left;
		}
	</style>
</head>
<body>
<div class="content">测试内容一</div>
<div class="content" style="float:right">测试内容二</div>
</body>
</html>

dir:设置元素中内容的排列方向;

<!DOCTYPE html>
<html>
<head>
	<meta name="author" content="Yeeku.H.Lee(CrazyIt.org)" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title> dir属性 </title>
</head>
<body>
<div dir="ltr">测试内容dir设为ltr</div>
<div dir="rtl">测试内容dir设为rtl</div>
<table width="500" border="1">
<tr>
<td dir="ltr">表格内容dir设为ltr</td>
<td dir="rtl">表格内容dir设为rtl</td>
</tr>
<table>
</body>
</html>

title:为HTML元素指定额外信息;

<!DOCTYPE html>
<html>
<head>
	<meta name="author" content="Yeeku.H.Lee(CrazyIt.org)" />
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title> title属性 </title>
</head>
<body>
<a href="http://www.fkjava.org" title="疯狂软件官网">疯狂软件</a>
<div title="测试标题">测试内容</div>
<table border="1" >
	<tr>
		<td title="单元格标题">单元格内容</td>
	</tr>
</table>
<table>
</body>
</html>

accesskey:指定激活该元素的快捷键

用户名(n):<input name="name" type="text" accesskey="n"/><br>
密码(p):<input name="pass" type="text" accesskey="p"/>
<a href="http://www.fkjava.org" accesskey="x">疯狂软件<a>

tabindex:用于控制窗口、HTML元素获取焦点的顺序

<a href="#" tabindex="2">疯狂Java联盟</a>
<a href="#" tabindex="1">HTML 5学习</a>
<a href="#" tabindex="3">Java学习</a>

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值