Html Div Tag

You can think of a website page in three major chunks. You’ve got the header và footer and, in between, the main body. But when looking at any website page, you can see the body toàn thân is made up of sections, too. There’s likely a section for products & services, testimonials, team members, liên hệ information, & more.

Bạn đang xem: Html div tag

Each of these sections probably looks a little different. Maybe they have different colors & fonts. Maybe one has a parallax background and one has a đoạn phim background. Maybe one is made up of multiple rows và columns, và so on.

This variation in styling is possible because of the nội dung division element in HTML. Better known as “div,” this element can divide your website page into sections so you can target them with chất lượng CSS properties.

*

In this post, we’ll take a closer look at what this element is, what it does exactly, & why you’d want to use it on your own site.


What is the
tag in HTML?


In HTML, the
tag is a generic block-level container for other elements.

Xem thêm: " Trú Quán Là Gì - “Nguyên Quán” Và “Quê Quán” Khác Nhau Như Thế Nào


Let’s look at a few key terms in this definition.

First, a div is a “generic” container because it doesn’t describe the content it contains. Other elements like , , , and clearly describe the nội dung they contain và are known as semantic HTML elements. You should always use a semantic element over a div when possible because it makes your code more accessible & easier khổng lồ maintain.

Second, a div is a block-level container. To understand what that means, let’s compare a div to a span element, which is an inline container.

The are several key differences between a block-level & an inline container. For example, a div always starts on its own line, whereas a span stays in line (inline — get it?). A div also takes up the full width of the page, & a span does not. That means that if you have multiple divs in a row, they will appear stacked on top of each other on the front end. Spans, on the other hand, can exist side by side. The last major difference is that you can define the height và width of a div, but you can’t for a span.

Third, the elements that can be contained in a div are known more specifically as “palpable content” or “flow content.” Palpable content is basically any HTML element that contains text or embedded content, and flow content is basically any element used in the body toàn thân of HTML docs. So the anchor, block quote, audio, image, paragraph, and heading elements are all considered palpable or flow content, and can be placed inside a div.

Where does a
tag go in HTML?

Divs go in the toàn thân section of an HTML file. This is clearly marked by