coding180 icon

Coding180

HTML Element: Div tag

HTML Element: Div tag

Tutorials > HTML > HTML Elements


Divs Element are commonly used to represent containers for other elements, visually grouping them into a block that can contain defined dimensions and position. 

By default, a div has no defined visual characteristics, this needs to be done via CSS when assigning borders, background, colors, etc. 

The main feature of div, however, is that it represents a block-type element, that is, when added to the page, it automatically generates a new line in the layout (similar to a paragraph), instead of being allocated laterally in the other components.

The code below demonstrates a basic use of divs.

<input type="text" value="input 1">
<input type="text" value="input 2">
<div><input type="text" value="input 3"></div>
<div><input type="text" value="input 4"></div>

Notice in the result of the image below, while the first two inputs are arranged laterally, the last two appear one below the other, since they are inside different divs.

Example of using DIVs

 


user

Robort Gabriel

Lagos, Nigeria

Freelance Web Developer, Native Android Developer, and Coding Tutor.

Skills
  • UI / UX
  • JavaScript
  • Python
  • PHP
  • Kotlin
  • Java
  • Bootrap
  • Android
  • Laravel