Centering a <div> can be done in several ways depending on the layout requirements. Here are some common methods:
1. Using Flexbox (Most Recommended)
2. Using CSS Grid
3. Using Absolute Positioning
4. Using Inline-Block and Text Alignment
5. Using Margin Auto
This works well when the div has a set width/height and is positioned inside a parent container.
Each method has its use case. Flexbox and CSS Grid are the most modern and versatile approaches for centering content. Which one you use depends on your specific requirements! 😊