+ 2

Centering text in the middle of a box

I am pretty new to any coding, just having fun learning at this point. I am trying to figure out how to center text vertically and horizontally within a box using CSS, but I’m not sure how. I used text-align: center, but that just centered it in the browser window. I have a box around my heading and I want the text to be centered in the box. Can anyone help with that?

17th Aug 2018, 4:29 AM
Jeremy Burke
Jeremy Burke - avatar
4 Respuestas
17th Aug 2018, 7:08 AM
Ravindra Desai
Ravindra Desai - avatar
+ 3
If this helps. Also there would be many other ways to center it. https://code.sololearn.com/W87twWcbZphL/?ref=app
17th Aug 2018, 6:14 AM
Meet Mehta
Meet Mehta - avatar
+ 1
Add a class to that text, .className{ margin-left:auto; marign-right: auto; } It will comes the text center.
17th Aug 2018, 5:18 AM
Karthik K
Karthik K - avatar
17th Aug 2018, 6:10 AM
Calviղ
Calviղ - avatar