Every element in HTML has a default display value which depends upon the element type. Block or inline are the default display value for the most of the elements.
Block Level Elements: A block-level element always starts on a new line and stretches out to the left and right as far as it can.
- div element: The div element is used as a container for other HTML elements. It has no required attributes. Style, class and id are the commonly used attributes.
Syntax:
<div>GFG</div>
Example-1:
<!DOCTYPE html><html><body><style>body {text-align: center;}h1 {color: green;}</style><!-- Div element. --><divstyle="background-color:black;color:white;padding:20px;"><h1>GeeksforGeeks</h1><h3>GeeksforGeeks is a scienceportal for geeks.</h3><h3>You can give reviews as well ascontribute posts on this portal.</h3></div></body></html>chevron_rightfilter_noneOutput:
Inline Elements: An inline element is the opposite of the block-level element. It does not start on a new line and takes up only necessary width.
- span element: The span element is used as a container for text. It has no required attributes. Style, class and id are the commonly used attributes.
Syntax:
<span>GFG</span>
Example-2:
<!DOCTYPE html><html><style>body {text-align: center;}h1 {color: green;}</style><body><!-- Sapn element. --><h1>Geeks<spanstyle="color:red">for</span>Geeks</h1></body></html>chevron_rightfilter_noneOutput 2:

Supported Browsers:
- Google Chrome
- Mozilla Firefox
- Edge
- Safari
- Opera
Recommended Posts:
- How to remove the space between inline-block elements?
- What is the difference between inline-flex and inline-block in CSS?
- What is the difference between display: inline and display: inline-block in CSS?
- How to prevent inline-block divs from wrapping ?
- Inline HTML Helper - HTML Helpers in ASP.NET MVC
- How does inline JavaScript work with HTML ?
- How to Shift Inline Elements When Text Bold on Hover using CSS ?
- CSS | max-inline-size Property
- How to write a:hover in inline CSS?
- Kotlin Inline classes
- CSS | border-inline Property
- CSS | border-inline-end Property
- CSS | min-inline-size Property
- CSS | inline-size Property
- CSS | inset-inline-end Property
- CSS | margin-inline-end Property
- CSS | margin-inline Property
- CSS | padding-inline-end Property
- CSS | inset-inline Property
- CSS | padding-inline Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


