Your CSS is working perfectly well, just missed understand how it works <p>
. By default, the width of a paragraph is 100%, even if the text contained in this does not take the whole width.
To get the desired effect, just change this feature with a float:left
, or even a display:inline-block
. Following functional example:
.reduzido { float:left; background-color: #fc9 }
.texto { clear:both }
<p class="reduzido">CONSULTÓRIO</p>
<p class="texto">Texto texto texto texto texto texto texto.</p>
This way you don’t have to unstructure your original HTML to get the desired effect, and the element continues with the block features. Note that it is convenient to use clear:both
or at least clear:left
in the next element, to ensure that it starts at the bottom line. With space for other things after the paragraph, other elements can stay on the same line without the clear
.
We do not know the code, but it seems to me that the most correct tag would be
<h1>
,<h2>
, etc., since it is a title - apparently.<p>
is meant to involve paragraphs themselves.– Andre Figueiredo