Home > Web Front-end > CSS Tutorial > How to use div layout?

How to use div layout?

little bottle
Release: 2020-09-17 10:44:59
Original
12519 people have browsed it

DIV is the positioning technology in cascading style sheets, the full name is DIVision, which means division. Sometimes they are called layers. DIV is also called integer divisibility in programming, that is, only the integers of the quotient can be obtained. The DIV element is an element used to provide structure and background for block-level content within an HTML (an application under Standard Universal Markup Language) document.

How to use div layout?

<div> is a block-level element. This means that its contents automatically start on a new line. In fact, line breaks are a specific formatting behavior inherent to <div>. Additional styles can be applied via the <div>'s class or id.

It is not necessary to add a class or id to every <div>, although there are certain benefits to doing so.

It is possible to apply both class and id attributes to the same <div> element, but it is more common to apply only one of them. The main difference between the two is that class is used for groups of elements (similar elements, or can be understood as a certain type of elements), while id is used to identify individual specific elements.

Example:

<body>
<h1>NEWS WEBSITE</h1>
<p>some text. some text. some text...</p>
...
<div class="news">
<h2>News headline 1</h2>
<p>some text. some text. some text...</p>
...
</div>
<div class="news">
<h2>News headline 2</h2>
<p>some text. some text. some text...</p>
...
</div>
...
</body>
Copy after login

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

Related labels:
source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template