MARCELO Posted July 5, 2018 Share Posted July 5, 2018 Hi. I used the property margin auto to center this buttom, but its not working out. I also tried to use margin left.... What s the property i should use to center a buttom? Thanks. https://www.w3schools.com/code/tryit.asp?filename=FSZ8WU7I5Q04 Link to comment Share on other sites More sharing options...
dsonesuk Posted July 5, 2018 Share Posted July 5, 2018 (edited) The anchor by default is INLINE, it has also has the property of display: inline-block; both of these means it will act as text would behave in a BLOCK paragraph element that has text-align: center; The margin: 0 auto; only works on BLOCK elements that are not floated and have a width that is smaller than the parent BLOCK element. Edited July 5, 2018 by dsonesuk Link to comment Share on other sites More sharing options...
MARCELO Posted July 5, 2018 Author Share Posted July 5, 2018 thanks Link to comment Share on other sites More sharing options...
webtrickshome Posted July 24, 2018 Share Posted July 24, 2018 Use html tag <center></center> as shown below to get it done easily or you can redefine its css property as display block and then margin auto. <center><a class="button" href="#"><span>GO! </span></a></center> Link to comment Share on other sites More sharing options...
dsonesuk Posted July 24, 2018 Share Posted July 24, 2018 No one ever uses center tag anymore in preference for css, also its not supported in HTML5, also to centre a block element with margin auto, a width is required. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now