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.
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
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:
You can apply class or id attributes to the same
[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 :
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:
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!