I am trying to create a style that applies background color to the title text. It's simple enough to include an inline element inside my heading, but problems arise when there is line break, because left padding only applies to the first line of text. To solve this problem, I apply a left border to my header tags, which properly supports left padding during line wrappers. However, I am having serious problems corresponding to the height of the left border with the background of inline elements in browsers. I pick it up in Chrome / Safari and it is disabled in Firefox etc. I created a fiddle to demonstrate:
http://jsfiddle.net/spidercoder/4KJn2/1/
My approach:
HTML:
<h1><span>Lorem ipsum dolor sit amet consectetur adipiscing elit.</span></h1>
CSS
h1{
color: white;
text-transform: uppercase;
font-family: sans-serif;
font-size: 34px;
line-height: 44px;
border-left: 10px solid black;
padding: 8px 0 7px 0;} // This tweaks the height of the left-border
h1 span{
white-space: pre-wrap;
background: black;
padding: 10px 10px 10px 0;}
, , , . , , .
- , , ? , , , , .
!