How to Use CSS in aligning buttons to the a particular side or Center | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to Use CSS in aligning buttons to the a particular side or Center

I have been trying to get a button aligned to the center but couldn't figure it out.

18th Nov 2019, 9:41 PM
Binkap S
Binkap S - avatar
5 Answers
+ 2
That's probably not the best way, but you can use the following code, it will align the button to center: button { width: 20%; margin-left: 40%; }
19th Nov 2019, 4:47 AM
Rick Sanchez
Rick Sanchez - avatar
+ 1
Use margins to align your button in center.
19th Nov 2019, 5:31 AM
Chetali Shah
Chetali Shah - avatar
+ 1
Thank you guys Really appreciate it Will try those Regards: Binkap S
19th Nov 2019, 8:08 AM
Binkap S
Binkap S - avatar
+ 1
Thanks Lovely
20th Nov 2019, 4:00 PM
Binkap S
Binkap S - avatar
0
Alternatively, instead of using CSS, you could put your button inside a div and align the div to the center normally with the HTML align="center" attribute.
19th Nov 2019, 9:02 PM
Njeri
Njeri - avatar