I am new to web dev, I was building a test site and I wanted a h1 tag with the background color only covering the text content of the tag and not extend to the whole width of the tag.
Visually, the h1 tag text should be center aligned with the browser's width and the background color should only encompass the text.
I have tried using the width attribute of the tag but it actually nullifies the alignment of the text to the browser's width.
Can I do it with CSS alone?