
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Role of margin property with value auto using CSS
The margin property with value auto is used to horizontally center the element within its container. You can try to run the following code to implement margin: auto;
Example
<!DOCTYPE html> <html> <head> <style> div { width: 200px; margin: auto; border: 2px dashed blue; } </style> </head> <body> <p>This is demo text</p> <div> This is horizontally centered because it has margin: auto; </div> </body> </html>
Output
- Related Questions & Answers
- Role of margin property with value inherit using CSS
- Usage of margin property with CSS
- Usage of margin-bottom property with CSS
- Usage of margin-right property with CSS
- Usage of margin-top property with CSS
- Role of CSS flex-wrap property wrap value
- Role of CSS flex-direction property column value
- Role of CSS flex-direction property row value
- Role of CSS justify-content property center value
- Animate CSS margin property
- Role of CSS justify-content property space-around value
- Role of CSS flex-wrap property wrap-reverse value
- Role of CSS flex-wrap property no-wrap value
- Role of CSS justify-content property flex-start value
- Role of CSS justify-content property flex-end value
Advertisements