I'm not sure Iām completely sure that I understand your question, but check out this script: http://jsfiddle.net/TJSdq/ and see what you want.
HTML
<div> This is my div and I love my divs. I take good care of my divs; they are my babies. </div>ā
CSS
div{ width:200px; height:200px; padding:20px; background-color:yellow; background-clip:content-box; -webkit-background-clip:content-box; border:2px solid black; } ā
However, if you want to color only part of a div asymmetrically, it is best to use sub divs and color the div instead. This method is preferable because it will have better browser support than the new CSS3 methods that I don't know about. In the final example, check out this script: http://jsfiddle.net/aD9mF/ .
HTML
<div> This is my first div. <div> This is my sub-div. </div> <div>ā
CSS
div{ width: 300px; height: 300px; border: 3px solid black; } div div{ background-color:yellow; width: 30px; height: 100%; float:left; border:none }
Akash source share