Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the Article and Section elements in HTML5

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the relevant knowledge of "how to use Article and Section elements in HTML5". Xiaobian shows you the operation process through actual cases. The operation method is simple, fast and practical. I hope this article "how to use Article and Section elements in HTML5" can help you solve the problem.

HTML5 introduces a number of new elements that will be widely used in the future. However, there are a few elements that are confusing when used, including two new elements: and.

The most frequently asked question is: Under what circumstances should we use these elements? And how do we use them correctly?

Section elements

This is one of the most ambiguous elements. What's the difference between it and elements? We've been using it to divide paragraphs, so except when we use this element. We quote official documents to illustrate it. According to the WHATWG documentation, elements are described as follows:

"Element represents a document or application, common paragraph- WHATWG"

From the description we can see that the function of the element is segmentation, more or less similar to. But there is one exception. In the document, a special statement was added:

"When an element is used only for style or for scripting convenience, we encourage authors to use it. Element applies when the element's content needs to be explicitly listed. - WHATWG"

Based on this, we can summarize the following two points:

First, although section elements are technically styleable, we recommend using div elements when there are complex styles or scripts.

Second, similar to elements, section elements are used to enumerate content.

So in a real-world example, the reason for using the element is to structure the content of the blog, and the code is as follows:

The code is as follows:

Blog Post Title

Ice cream tart powder jelly-o.

Gummies chocolate cake ice cream cookie halvah tiramisu jelly-o.

Blog Post Title

Ice cream tart powder jelly-o.

Gummies chocolate cake ice cream cookie halvah tiramisu jelly-o.

Blog Post Title

Ice cream tart powder jelly-o.

Gummies chocolate cake ice cream cookie halvah tiramisu jelly-o.

This is just an example; elements can also be used for other purposes.

Article Elements

From the name, it has a good description of itself, but we still have to see how the official documents describe it:

"A separate section of a document, page, application, or site that, in general, can be allocated independently or reused, such as at publication. This could be forum posts, magazine or news items, blog entries, user-submitted comments, interactive gadgets or widgets, or any other independent project content. "

From the above description, we can conclude that elements are dedicated to structured articles, especially those we want to publish, such as blogs, page content, or forum posts.

The following example shows how to build a blog post using.

The code is as follows:

This is Blog Post Title

Author Name

Save in Categories

Sweet roll halvah biscuit toffee liquorice tart pudding sesame snaps.

Biscuit powder jelly-o fruitcake faworki chocolate bar. Pudding oat

cake tootsie roll sesame snaps lollipop gingerbread bonbon. Gummies

halvah gummies danish biscuit applicake gingerbread jelly-o pastry.

In addition, elements can be combined with section elements, which can be used to divide articles into paragraphs if desired, as shown in the following example.

The code is as follows:

This is Blog Post Title

Author Name

Save in Categories

This is the Sub-Heading

Sweet roll halvah biscuit toffee liquorice tart pudding sesame snaps.

Biscuit powder jelly-o fruitcake faworki chocolate bar. Pudding oat cake

tootsie roll sesame snaps lollipop gingerbread bonbon. Gummies halvah

gummies danish biscuit applicake gingerbread jelly-o pastry.

This is another Sub-Heading

Topping cheesecake sweet pie carrot cake sweet roll. Gummi bears lemon drops

toffee sesame snaps tart topping chupa chups apple pie gummies. Wafer chocolate

cake. Sugar plum chocolate bar topping ice cream carrot cake danish bonbon.

Cheesecake gummi bears dragée jujubes dragée dragée brownie jelly biscuit. Powder croissant jelly beans pastry.

The content of "How to use Article and Section elements in HTML5" is introduced here. Thank you for reading it. If you want to know more about industry-related knowledge, you can pay attention to the industry information channel. Xiaobian will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report