“Füllen Sie den Farb -Behid -Text in HTML” Code-Antworten

Füllen Sie den Farb -Behid -Text in HTML

Put the text in an inline element, such as a <span>.

<h1><span>The Last Will and Testament of Eric Jones</span></h1>
And then apply the background color on the inline element.

h1 {
    text-align: center; 
}
h1 span { 
    background-color: green; 
}
An inline element is as big as its contents is, so that should do it for you.
Ankur

Füllen Sie den Farb -Behid -Text in HTML

Option 1
display: table;

no parent required
h1 {
    display: table; /* keep the background color wrapped tight */
    margin: 0px auto 0px auto; /* keep the table centered */
    padding:5px;font-size:20px;background-color:green;color:#ffffff;
}
<h1>The Last Will and Testament of Eric Jones</h1>
Ankur

Ähnliche Antworten wie “Füllen Sie den Farb -Behid -Text in HTML”

Fragen ähnlich wie “Füllen Sie den Farb -Behid -Text in HTML”

Weitere verwandte Antworten zu “Füllen Sie den Farb -Behid -Text in HTML” auf HTML

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen