
- HTML Tutorial
- HTML - Home
- HTML - Overview
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Comments
- HTML - Images
- HTML - Tables
- HTML - Lists
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Frames
- HTML - Iframes
- HTML - Blocks
- HTML - Backgrounds
- HTML - Colors
- HTML - Fonts
- HTML - Forms
- HTML - Embed Multimedia
- HTML - Marquees
- HTML - Header
- HTML - Style Sheet
- HTML - Javascript
- HTML - Layouts
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- HTML - Fonts Ref
- HTML - Events Ref
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
How to make a div center align in HTML?
To center div element center ,you can use "div style="text-align:center" " and to center the div ,use "div style="margin: 0 auto" "
In your code, the above css will be written as −
<div style="text-align:center;width: 300px;margin: 0 auto;border-style: dotted;"> <p>hi</p> </div>
Output
- Related Articles
- How to center align text in table cells in HTML?
- How to center a div within another div?
- How to align block elements to the center?
- Center Triangle at Bottom of Div in HTML with CSS
- Center one and right/left align other flexbox element in HTML
- How to center align the items of a JComboBox in Java?
- How can I vertically align elements in a div?
- How to center a div on the screen using jQuery?
- How to center align component using BoxLayout with Java?
- How to align flexbox container into center using JavaScript?
- How to align text content into center using JavaScript?
- Center image using text-align center with CSS?
- Align items to center not working in SAPUI5
- How to Align Navbar Items to Center using Bootstrap 4?
- How to center text in HTML?

Advertisements