博客列表 >HTML基本标签与CSS选择器-2018年8月10号23:00

HTML基本标签与CSS选择器-2018年8月10号23:00

EmonXu的博客
EmonXu的博客原创
2018年08月13日 00:59:42602浏览

    学习前端开发,必须掌握html及CSS的相关知识,这里介绍一下HTML的基本文档结构与常用标签,以及CSS常见选择器,供大家参考学习。

    下列代码,为示例代码。

实例

<!DOCTYPE html> <!-- 声明,可换成xml/xhtml -->
<html>
<head> <!-- 网页头部 -->
	<title>php学习-0810作业</title>
	<meta charset="utf-8">  <!-- 字符集编码,必需 -->
	<link rel="stylesheet" type="text/css" href="static/style.css">  <!-- link链接外部文件 --> <!-- 外部样式 -->
	<link rel="shortcut icon" type="image/x-icon" href="icon/ball.png"> <!-- 链接外部图片,显示在网页头部 -->

	<style type="text/css"> /*内部样式:只针对当前页面*/
	body{background: red} /*标签/标记选择器*/  /*内部样式优先级大于外部样式*/
    #box{width: 200px;height: 200px;background: pink}  /*id选择器*/
    .main{width: 300px;height: 300px;background: green}  /*class类选择器*/
	a{color: blue}
	a[href="http://www.php.cn"]{color:pink } /*属性选择器*/
	a[href="test2.html"]{color:yellow } /*属性选择器*/
	div a{color: blue} /*派生选择器*/
    #box a{color: red} /*派生选择器*/
	</style>
</head>
<body>
<img src="https://img.php.cn/upload/article/000/000/003/5b596217c2850304.jpg">
<a href="http://www.baidu.cn">百度</a>
<a href="http://www.php.cn">PHP中文网</a>
<a href="test2.html">测试网页</a>
<div id="box">
<a href="">php</a>
</div>
<div class="main">
<a href="" style="color:yellow">php2</a> <!-- 内联样式,内联样式优先级大于内部样式 -->
</div>
</body>
</html>

运行实例 »

点击 "运行实例" 按钮查看在线实例

以下为手抄代码:

手抄代码1-小图.jpg

手抄代码2-小图.jpg

声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议