- HTML 基础教程
- HTML 简介
- HTML 编辑器
- 基本的 HTML 标签
- HTML 元素
- HTML 属性
- HTML 标题
- HTML 段落
- HTML 样式
- HTML 文本格式化
- HTML 引用
- HTML 计算机代码元素
- HTML 注释
- HTML CSS
- HTML 链接
- HTML 图像
- HTML 表格
- HTML 列表
- HTML <div> 和 <span>
- HTML 类
- HTML 布局
- HTML 响应式 Web 设计
- HTML 框架
- HTML Iframe
- HTML 背景
- HTML 脚本
- HTML 头部元素
- HTML 字符实体
- HTML 统一资源定位器
- HTML URL 字符编码
- HTML Web Server
- HTML 颜色
- HTML 颜色名
- HTML文档类型
- HTML 4.01 快速参考
- HTML XHTML
- XHTML 简介
- XHTML - 元素
- XHTML - 属性
- HTML 表单
- HTML 表单
- HTML 表单元素
- HTML 输入类型
- HTML Input 属性
- 实例
- HTML 实例
- HTML 参考手册
- HTML 参考手册
- HTML 全局属性
- HTML 事件属性
- HTML 元素和有效的 DTD
- HTML 颜色名
- HTML 字符集
- HTML ASCII
- HTML ISO-8859-1
- HTML 4.01 符号实体
- HTML URL 编码
- HTML 语言代码
- HTTP 状态消息
HTML 类
对 HTML 进行分类(设置类),使我们能够为元素的类定义 CSS 样式。
为相同的类设置相同的样式,或者为不同的类设置不同的样式。
实例
<!DOCTYPE html> <html> <head> <style> .cities { background-color:black; color:white; margin:20px; padding:20px; } </style> </head> <body> <div class="cities"> <h2>London</h2> <p> London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants. </p> </div> </body> </html>
分类块级元素
HTML <div> 元素是块级元素。它能够用作其他 HTML 元素的容器。
设置 <div> 元素的类,使我们能够为相同的 <div> 元素设置相同的类:
实例
<!DOCTYPE html> <html> <head> <style> .cities { background-color:black; color:white; margin:20px; padding:20px; } </style> </head> <body> <div class="cities"> <h2>London</h2> <p>London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p> </div> <div class="cities"> <h2>Paris</h2> <p>Paris is the capital and most populous city of France.</p> </div> <div class="cities"> <h2>Tokyo</h2> <p>Tokyo is the capital of Japan, the center of the Greater Tokyo Area, and the most populous metropolitan area in the world.</p> </div> </body> </html>
分类行内元素
HTML <span> 元素是行内元素,能够用作文本的容器。
设置 <span> 元素的类,能够为相同的 <span> 元素设置相同的样式。
实例
<!DOCTYPE html> <html> <head> <style> span.red {color:red;} </style> </head> <body> <h1>My <span class="red">Important</span> Heading</h1> </body> </html>