Coding CommunityE-Learning

Learn HTML-CSS “How To Align a div to The Middle horizontally on a Page?

horizontal align css

Are you looking for aligning a <div> tag horizontally to the middle of the page using CSS? If so, you have come to the right place.

Aligning a <div> tag horizontally to the middle of the page using CSS can be done with the help of the code shown below.

HTML

CSS

The above code does the job. However, you may want to make sure that no issues arise when you are using IE6. To make it work for IE6, you need to add “text-align: center” to the body and then add “simple text-align: left” to your div to make everything work. Easy, right? These corner cases will ensure that your code works on every browser out there and can be used by anyone on the web.

That’s all! Do you have any other trick that can help? If yes, don’t forget to share it in the comment section below.

You can also check on our website for videos on HTML/CSS. Below are some examples:

  • HTML5/CSS/JS (Full HTML markup process) (part 12) – HTML-CSS

  • [PT/EN] Website From Scratch (part 10) – HTML-CSS

You can also follow some of our broadcasters who program in JavaScript as below:

 Chocsx

 alexsimkovich

Another cool way to find out interesting things about HTML/CSS is to access our project page!

About author

About Author Dr. Michael Jurgen Garbade is the founder of LiveEdu.TV, Kyuda, Education Ecosystem. He is future Venture Capitalist, Future Politician and always on the lookout for the Next Big Challenge. Obtained Masters in business administration and physics, and a Ph.D. in finance with professional work experience in high-paced environments at Fortune 500 companies like Amazon and General Electric. Expertize: Python, PHP, Sencha Touch & C++, SEO, Finance, Strategy & E-commerce. He speaks English and German and has worked in the US, Europe, and Asia. At Education Ecosystem he is the CEO and runs business operations.
Related posts
Career DevelopmentCybersecurity

Top 12 Free Projects to Become a Cybersecurity Expert in 2020

Career DevelopmentCoding Community

10 Python Projects to Learn from Home During Quarantine

Career DevelopmentData Science

Machine Learning Projects to Practice During Quarantine

Frontpage

Top 10 Web Development Frameworks of 2020