Home > Article > Web Front-end > How to center two lines of text in the same row_html/css_WEB-ITnose
<div> 11111111111111111111111111111111111111<span><h2 style="text-align:center;">222</h2></span></div>
<div> <span style="float:left;">11111111111111111111111111111111111111</span><h2 style="margin:0 auto;width:200px;text-align:center;">222</h2></div>
Set h1{display:inline;} to be on the same line; then add a few to open up the position
Try this, I changed the width to 100%, so that 222 is centered on any screen
<div> <span style="float:left;">11111111111111111111111111111111111111</span><h2 style="margin:0 auto;width:100%;text-align:center;">222</h2></div>