How do I make background colour fit but not go across the whole screen

Here is what I mean, currently when I view the code it looks like this

I want the same background but it’s shorter so it doesn’t fill the whole screen but not too short that it doesn’t fit the text

Like this

I tried using <br> but that doesn’t work.
Here is the code.

<h2 id="title">Test text for an <mark>Example</mark></h2>


#title {
    background-color: rgba(0, 193, 255,0.25);
    padding: 10px;
    border-radius: 10px;
    
  }
  mark {
    border-radius: 10px;
  }

1 Like

Hi, check out the answers to this SO question: css h1 - only as wide as the text - Stack Overflow

Hope it helps!

1 Like

It worked, thanks!

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.