Home > Enterprise >  How do I center this button using HTML or CSS
How do I center this button using HTML or CSS

Time:01-26

I am not very experienced with coding but the company I work at has tasked me with fixing our website. I am trying to figure our how to center this button on the page. enter image description here

the code that was on the template for the buttons enter image description here

also this code as well enter image description here

Could someone please help me out by telling me what I should do to move this button?

I tried to use the margin 0; thing in a couple spots but honestly got kind of lost.

CodePudding user response:

Try using margin: auto; that should allow you to have the same amount of margin on both sides. If that doesn't work, add width: 50%.

CodePudding user response:

I see you are using a table for your layout, this is an old way of doing it. To days standard suggests that you use Grid or flexbox.

To center an element with margin you specify the width of the element you want to center. Then you can do something like: (example from W3Scrools: https://www.w3schools.com/css/tryit.asp?)

.center {
  margin: auto;
  width: 60%;
  border: 3px solid #73AD21;
  padding: 10px;
}

You can also take a look at Kevin, he has a youtube channel where he teaches CSS and HTML. https://www.youtube.com/watch?v=ULVu2VNM_54 I think you will find it most useful.

Happy coding.

  • Related