Home  >  Article  >  Web Front-end  >  How to use div tags

How to use div tags

清浅
清浅Original
2018-12-13 13:06:3821543browse

How to use div tags: 1. The div tag can get the style by setting class or id; 2. The div tag can also get the style directly through the inline method.

How to use div tags

The operating environment of this article: Windows 7 system, Dell G3 computer, HTML5&&CSS3 version.

Use of div tags: div tags can obtain styles by setting class or id, or directly obtain styles through inline methods

dc6dce4a544fdca2df29d5ac0ea9906b tags can divide the document into Separate, distinct parts. It can be used as a strict organizational tool and does not use any formatting associated with it. Next, in the article, I will introduce how to use div, which has certain reference value. I hope it will be helpful to everyone.

div meaning:

div tag is called Separation tags can define partitions or sections in a document, with the purpose of dividing the document into independent and different parts. It can set the position of text, images, tables and other elements

div is an element used to provide structure and background for block-level content within an HTML document. Everything between the start and end tags of the div is used to form this block, and the properties of the contained elements will be controlled by the attributes of the div tag, or by using a style sheet.

Usage of div:

dc6dce4a544fdca2df29d5ac0ea9906b is a block-level element, which means that its content will automatically occupy one line. Additional style properties can be obtained through the class or id of the div, but there is no need to add a selector to each div.

You can apply class or id attributes to the same dc6dce4a544fdca2df29d5ac0ea9906b element, but generally only one of them is applied. The main difference between the two is that class is used for class elements (can be understood as a certain type of elements), while id is used to identify individual and unique elements.

[Recommended course: HTML course]

Example: Usage without adding selector to div

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
 <div style="color:pink">
  <h1>div的用法</h1></div>
</body>
</html>

Rendering :

How to use div tags

Example: Add a class selector to div

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
.demo{
width:450px;
height: 300px;
background: pink;
text-align: center;
line-height: 300px;
font-size: 20px;
}
</style>
</head>
<body>
 <div>div的用法</div>
</body>
</html>

Rendering:

How to use div tags

Summary: The above is the entire content of this article. I hope it will be helpful to everyone learning div

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

Statement:
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