There are several other ways of doing this also: Set the width of each element : h1{background-color: #00ff00; width:33%;}
Use the float property, Then position each element:
h1{background-color: #00ff00; float:left;}
The simplest way tho, if you can edit the HTML, is use display inline and a BR after each heading.:
<html><head><style type="text/css">body {background-color: yellow}h1{background-color: #00ff00; display:inline;}h2 {background-color: transparent}p {background-color: rgb(250,0,255)}</style></head><body><h1>This is header 1</h1><br><h2>This is header 2</h2><p>This is a paragraph</p></body></html>