This article introduces the detailed usage of HTML div tags. You can use divs without css. Although it is less useful, it is still somewhat useful. However, if you add css, it can better display the div tags. For specific usage, here is an introduction to the meaning of HTML div. Just take a look. Let’s take a look at it now
First of all, let’s talk about the meaning and usage of div:
Here is the definition introduction of div:
If you use id or class to mark
Here is an introduction to the usage of div:
It is not necessary to add a class or id to every
It is possible to apply either class or id attributes to the same
HTML div tag prompt box:
Tips: The
Tip: By default, browsers usually place a line break before and after the
Let’s analyze a case now:
<body> <h1>PHP中文网</h1> <p>编程语言教室,里面有很多课程...</p> ... <div class="news"> <h2>php中文网首页 1</h2> <p>关于HTML5的东西都在这里...</p> ... </div> <div class="news"> <h2>php中文网首 2</h2> <p>关于HTML的东西都在这里...</p> ... </div> ... </body>
The effect of this case is as shown in the figure:
Now let’s explain the example situation:
As you can see, the above HTML simulates the structure of a news website. Each of these divs combines the title and summary of each news item, which means that the divs add additional structure to the document. At the same time, since these divs belong to the same type of elements, you can use class="news" to identify these divs. This not only adds appropriate semantics to the divs, but also facilitates further use of styles to format the divs, which kills two birds with one stone.
Okay, the above are all the usages of HTML div tags, because many usages are used together with css, so this is the only point without using css styles. I hope everyone can learn css as soon as possible. If you have any questions, you can Question below
[Editor’s recommendation]
What is the function of HTML meta tag? Introduction to how to use html meta tag
#How to use html base tag? How to use the base tag (with examples)
The above is the detailed content of How to use HTML div tag? Here are examples of how to use div. For more information, please follow other related articles on the PHP Chinese website!