-2

I am wondering, is there a way you can make the span tag move into the center using css?

I need to ask this question because whenever I put text-align in the span, it doesn't work.

Html

<span>
This is span.
</span>`

Css

span {
text-align:center;
}
Sur
  • 191
  • 2
  • 3
  • 14

1 Answers1

1

To just horizontal center the text inside an element, use text-align: center;. And for both on a text:

<!DOCTYPE html>
<html>
<head>
<style>
.center {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 200px;
  border: 3px solid green; 
}
</style>
</head>
<body>

<div class="center">
  <p>I am vertically and horizontally centered.</p>
</div>

</body>
</html>
zerbene
  • 1,249
  • 2
  • 7
  • 21