I have an H1 style for my site:
.centercol h1 {
color: #006bb6;
font-weight: normal;
font-size: 18px;
padding:3px 3px 3px 6px;
border-lef
You can use display:inline-block to force this behavior
.h1 {
width: -moz-fit-content;
width: fit-content;
// workaround for IE11
display: table;
}
All modern browsers support width: fit-content for that.
For IE11 we could emulate this behavior with display: table which doesn't break margin collapse like display: inline-block or float: left.
You can use the inline-block value for display, however in this case you will loose the block feature of h1 i.e. the siblings will be displayed inline with h1 if they are inline elements(in which case you can use a line-break
).
display:inline-block;