Align a button? | Sololearn: Learn to code for FREE!


Align a button?

For my code, I need the button to be aligned to the center, but I can't change its position. Does anyone know how to center the button?

6/6/2020 6:30:09 PM


13 Answers

New Answer


Nicole <center> <button>Test</button> </center> Kindly prefer to use our searchbar before asking a new question Some of them , I've listed below πŸ‘‡πŸ‘‡πŸ‘‡


You can do it by css too. Text-align: center;


Of course. Could you link your code please?


πŠπ’π’π›π¨ π†π‘πšπ²πšπ₯ why are you promoting <center> tag? You know better than that? <center> tag is deprecated in HTML5: <style> #btn { text-align: center; } </style> <div id=β€œbtn”> <button>Button</button> </div> (Don’t take it too personal... I am an HTML4 guy, so I have many, many web pages with <center> in them. But I am sloooowly converting my code to HTML5. lol )


Code Crasher That's why I've provided the links


πŠπ’π’π›π¨ π†π‘πšπ²πšπ₯ I humbly apologize if the links provide the answer. I didn’t click on them. (sorry πŸ₯Ί)



πŠπ’π’π›π¨ π†π‘πšπ²πšπ₯ Thank you!


Ja Play It's okay, thanks for your concern!


Change display:block Set :width Margin:auto Try this




<div> <input type="button" value="press"> </div>


You can do it by ccs and java also