HTML CSS examples for HTML Tag:div
The div element marks the structure. It is used to group other elements.
We can add style to the div element to change the layout.
The div element is the block element equivalent of the span element.
The div Element summary
Item | Value |
---|---|
Item | Description |
Element | div |
Local Attributes | None |
Tag Style | Start and end tag required |
New in HTML5 | No |
Changes in HTML5 | None |
Style Convention
div {
display: block;
}
Using the div Element
<!DOCTYPE html> <html> <head> <title>Example</title> <style> .favorites {<!--from w w w . j a v a 2s . c o m--> background:grey; color:white; border: thin solid black; padding: 0.2em; } </style> </head> <body> <div class="favorites"> <p>I like CSS and HTML.</p> </div> </body> </html>