Forum Moderators: not2easy
In your style sheet:
.box {
border : 1px solid black;
padding : 10px;
}
.title {
position : relative;
top : 10px;
left : 25px;
border-left : 1px solid black;
border-right : 1px solid black;
background-color : white;
padding : 0 5px;
}
In your body:
<span class="title">Title</span>
<div class="box">
This is content text. There is nothing here. If you want something here, then put something here.
</div>
Note that this will create some "dead space" above the div equal to the height of the title.
In your style sheet:
.box
{
margin: 30px 5px 15px 10px;
border: #3c5a86 1px dashed;
padding:5px;
font-size: 12px;
font-weight: normal;
color: #000000;
background-color: #d1e0ef;
}
.box H1
{
margin : 0px 0px -12px 5px;
position: relative;
top : -12px;
border: #3c5a86 1px solid;
padding-top : 3px;
padding-bottom: 3px;
padding-left : 5px;
padding-right : 5px;
font-size : 18px;
font-weight: bold;
color : #000000;
display: inline;
background-color: #99bbdd;
}
and for the body
<div class=box>
<h1>This is the Title</h1>
<p>This is the text</p>
</div>
You can achieve the same effect by floating the title and using a negative margin to pull it out if the div. This has the benefit of not preserving the space that using position relative does.
e.g.(in the h1 style)
float:left;
margin-top : -12px;
instead of:
position:relative;
top: -12px
Similar result but less gap between title and text :)
Paul