Skip to main content

Posts

How to center a div using HTML and CSS.

Introduction This blog is about how to center a div using CSS. There are various techniques available, and depending on the layout you are working with, some methods may be more suitable than others. Before exploring it, you have to make sure that you have basic knowledge of HTML tags and CSS property and selectors for better understanding. We will cover three different methods to center a div. 1. Using the Flex Property Suppose we have a parent container and a child container and Inside the parent container we want to center a child container. so we can use the flexbox property. HTML Code :      < div class = "parent-container" >         < div class = "child-container" >         </ div >     </ div > CSS Code :      < style >         .parent-container {             width : 600px ;             hei...