简体   繁体   中英

HTML CSS Centering part of text inside a paragraph

How would I manage to center a part of text which is inside a paragraph?

Example I have a paragraph :

<p id="hello">Hello : <span id="love">I love you</span> very much</p>

And I want the "I love you" part to be in a new row in center (thats why I tried with span) then rest of the paragraph new row but normal align.

I have tried like this but wont work :

now in css I have :

#hello {
    font-size:22px;
    margin: 2em;
}

#love {
    text-align:center;
}

Any suggestions?

#love {
    display:block;
    text-align:center;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM