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

+3

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

Nicole

13 Answers

New Answer

+5

Nicole <center> <button>Test</button> </center> Kindly prefer to use our searchbar before asking a new question Some of them , I've listed below 👇👇👇 https://www.sololearn.com/Discuss/1298119/?ref=app https://www.sololearn.com/Discuss/719585/?ref=app https://www.sololearn.com/Discuss/1592719/?ref=app https://www.sololearn.com/Discuss/1825755/?ref=app https://www.sololearn.com/Discuss/112764/?ref=app https://www.sololearn.com/Discuss/1360092/?ref=app https://www.sololearn.com/Discuss/1619561/?ref=app

+4

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

+2

Of course. Could you link your code please?

+2

𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 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 )

+2

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

+2

𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 I humbly apologize if the links provide the answer. I didn’t click on them. (sorry 🥺)

+2

<center><button></button></center>

+1

𝐊𝐢𝐢𝐛𝐨 𝐆𝐡𝐚𝐲𝐚𝐥 Thank you!

+1

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

0

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

0

Text align=" center"

-1

You can do it by ccs and java also

-1

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