- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Display Block using CSS
Using display property value block makes an element to begin on a new line. With that, it takes the entire width. Therefore, the element is displayed as a block element.
Example
Let us now see an example to implement display block in CSS −
<!DOCTYPE html> <html> <head> <style> p { background-color: orange; color: white; } p.demo1 { display: block; } p.demo2 { display: inline-block; } </style> </head> <body> <h1>Match Details</h1> <div> Match will begin at <p class="demo1">10AM</p> on 19th Decemenber, 2019. </div> <hr /> <div> Match will end at <p class="demo2">5PM</p> on 19th Decemenber, 2019. </div> </body> </html>
Output
Let us now see another example −
<!DOCTYPE html> <html> <head> <style> p { background-color: orange; color: white; } p.demo { display: block; } </style> </head> <body> <h1>Student Result</h1> <div> The result of MCA student will be declared on <p class="demo">20th Decemeber 2019</p>Check the website on the same day at 8PM. </div> </body> </html>
Output
- Related Articles
- Display Inline-Block using CSS
- Working with Display Block in CSS
- Display Inline-Block Working with CSS
- Display Inline using CSS
- Display Property Using in CSS
- Display None Using in CSS
- Block-level Elements and Block Boxes in CSS
- Changing the Default Display Value using CSS
- Display an Icon from Image Sprite using CSS
- Who to Change the Default Display Value using CSS
- Display None in CSS
- CSS Visibility vs Display
- How to display columns and rows using named CSS grid items
- How to style block buttons (full-width) with CSS?
- Display Inline Working with CSS

Advertisements