headers Block size

2

So guys, I'd like some help here with css.

For example:

I have an h3

<h3> Bem Vindo ao Portal do Cliente </h3>

When I go to see in the browser, I have the text and box of h3.

WhatIwantedtodowasmaketheh3boxthesizeofthetext.Thatis,thewidthwouldbelimitedtotheendofthetextautomaticallywithouthavingtoreportasizeinpixels.

Removethatspaceafterthetext.

Canyoudothis?

YoumaynoticethatIputwidthwithsmallsizebuttheboxofh3remainslargealthoughthetextIhaveshrunk.Notethatafterthetextthereisacoloredparttotheendoftheline.

    
asked by anonymous 24.07.2017 / 15:49

3 answers

2

Try this:

header{
   border: 1px solid black;
   border-radius: 10px;
   float: left;
}
h3{
   display: inline;
}
<header>
    <h3>Bem Vindo ao Portal do Cliente</h3>
  </header>

Or so:

header{
   border: 1px solid black;
   border-radius: 10px;
   float: left;
}
<header>
    <h3>Bem Vindo ao Portal do Cliente</h3>
  </header>
    
24.07.2017 / 15:57
1

h3 {
  float: left;
}
<h3> Bem Vindo ao Portal do Cliente </h3>

    
24.07.2017 / 15:56
1

I saw you have already given the correct answer. But there was an explanation for what happened.

H3 defaults to a% w / o so that it serves as a header by taking up all the line space so that your text starts underneath it. So even if you decrease its width, it will still occupy the entire space with border (orange).

Then two two options, if you wanna be a display: block; , although I do not see why it would be necessary, it would be or do as they indicated with h3 , because that way you would make it float left and release your margin, or change the display to float: left; , because then it would be treated as any text and would not take up all the space.

    
24.07.2017 / 16:08