Home > Web Front-end > HTML Tutorial > How to use DIV in HTML

How to use DIV in HTML

php中世界最好的语言
Release: 2017-11-22 17:51:09
Original
8341 people have browsed it

As a commonly used tag in our html web pages, div's default style is to occupy a separate line. If you create a DIV, its CSS style needs to be reassigned. Style settings such as div width and height, internal font size, and font color all need to be implemented through CSS.

Generally speaking, the function of div is to realize layout, control the content style, and achieve various layout effects.

Usage example of DIV, here you can observe the effect by setting different CSS styles on the div.

Complete HTML source code of the example:

<!DOCTYPE html> 
<html> 
<head> 
<meta charset="gb2312" /> 
<title>div的用法在线演示 m.sbmmt.com</title> 
<style> 
div{ margin-top:10px}/* css注释说明:对div都设置上间距10px */ 
.div-1{font-size:16px}/* 设置css字体大小16px */ 
.div-2{color:#F00}/* 设置css字体颜色为红色 */ 
.div-3{ background:#000; color:#FFF}/* 设置CSS背景颜色为黑色和字体颜色为白色 */ 
.div-4{ border:1px solid #F00; height:60px}/* 设置css边框和CSS高度60px */ 
</style> 
</head> 
<body> 
<div>普通内容一</div> 
<div class="div-1">我字体大小为16px</div> 
<div class="div-2">我字体颜色为红色</div> 
<div class="div-3">我背景为黑色字体为白色</div> 
<div class="div-4">布局设置边框和高度</div> 
</body> 
</html>
Copy after login

There are so many uses of DIV. For more exciting information, please pay attention to other related articles on the php Chinese website!

Related reading:

How to write anchor text in html

What is the role of comments in html

Does ie6 support hover?

The above is the detailed content of How to use DIV in HTML. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template