Ask coding questions

← Back to all posts
How can I center my <H1> elements
TriciaKennedy (7)

Trying to center h1 element tag

Comments
hotnewtop
timmy_i_chen (1151)

Have you looked into using text-align: center; in your CSS yet?

roboticmind (1)
<center></center> should also work depending on how you have it set up
TriciaKennedy (7)

ok I got it centered but I am trying to center a img [email protected]

Yamboy1 (38)

@TriciaKennedy You could use the following css

img {
  margin-left: auto;
  margin-right: auto;
  display: block;
}

Heres an example repl: https://repl.it/@Yamboy1/WellmadeOnerlookedSites