CSS
The CSS Display Property – Display-Block, Inline-Block, None
In CSS (Cascading Style Sheets), the display property is used to control how an HTML element is rendered on a web page. There are several possible values for the display property, including block, inline-block, and none. Each of these values affects how the element is positioned and how it interacts with other elements on the page. Here’s an overview of these three values:
¶display: block
:
- Elements with
display: block
are rendered as block-level elements. They typically start on a new line and take up the full available width of their containing element. Common examples of block-level elements include<div>
,<p>
, and<h1>
. - Block-level elements can have width and height specified and can also have margins, padding, and borders.
- Block-level elements create a “block formatting context,” which means they stack on top of each other vertically by default.
¶display: inline-block
:
- Elements with
display: inline-block
are a hybrid between block-level and inline elements. They are inline with the text flow but can have width, height, margins, padding, and borders, just like block-level elements. - Inline-block elements do not start on a new line, and they can sit next to other elements horizontally, just like inline elements, but they can have block-level styling properties.
- This is often used for creating elements like buttons or navigation menus that need to be inline but have some block-level properties.
¶display: none
:
- Elements with
display: none
are not rendered on the page at all. They are completely hidden and do not take up any space. - This is commonly used to hide or remove elements from the page dynamically using JavaScript or for hiding elements that should not be visible until a certain condition is met.
- Elements with
display: none
are not accessible or interactable by the user. Here’s an example of how you might use thesedisplay
values in CSS:
/* Block-level element */
.block-element {
display: block;
width: 200px;
height: 100px;
margin: 10px;
padding: 5px;
border: 1px solid #000;
}
/* Inline-block element */
.inline-block-element {
display: inline-block;
width: 150px;
height: 50px;
margin: 5px;
padding: 3px;
border: 1px solid #333;
}
/* Hide an element */
.hidden-element {
display: none;
}
How to Add Comments in CSS ?
How To Work CSS Size - Width, Height, Max-Height, Max-Width Also Padding And Marging
All Tutorials in this playlist
Popular Tutorials
Categories
-
Artificial Intelligence (AI)
11
-
Bash Scripting
1
-
Bootstrap CSS
0
-
C Programming
14
-
C#
0
-
ChatGPT
1
-
Code Editor
2
-
Computer Engineering
3
-
CSS
28
-
Data Structure and Algorithm
18
-
Design Pattern in PHP
2
-
Design Patterns - Clean Code
1
-
E-Book
1
-
Git Commands
1
-
HTML
19
-
Interview Prepration
2
-
Java Programming
0
-
JavaScript
12
-
Laravel PHP Framework
37
-
Mysql
1
-
Node JS
1
-
Online Business
0
-
PHP
28
-
Programming
8
-
Python
12
-
React Js
19
-
React Native
1
-
Redux
2
-
Rust Programming
15
-
SEO - Search Engine Optimization
1
-
Tailwind CSS
1
-
Typescript
10
-
Uncategorized
0
-
Vue JS
1
-
Windows Operating system
1
-
Woocommerce
1
-
WordPress Development
2
Tags
- Artificial Intelligence (AI)
- Bash Scripting
- Business
- C
- C Programming
- C-sharp programming
- C++
- Code Editor
- Computer Engineering
- CSS
- Data Structure and Algorithm
- Database
- Design pattern
- Express JS
- git
- Git Commands
- github
- HTML
- Java
- JavaScript
- Laravel
- Mathematics
- MongoDB
- Mysql
- Node JS
- PHP
- Programming
- Python
- React Js
- Redux
- Rust Programming Language
- SEO
- TypeScript
- Vue JS
- Windows terminal
- Woocommerce
- WordPress
- WordPress Plugin Development