Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create div with title header [closed]

Tags:

html

css

How would i create the below using pure CSS (no images, no tables, no javascript)? alt text http://img530.imageshack.us/img530/3209/divs.png

like image 332
n002213f Avatar asked Mar 31 '10 10:03

n002213f


People also ask

Does div require a closing tag?

Div tag has both open(<div>) and closing (</div>) tag and it is mandatory to close the tag. The Div is the most usable tag in web development because it helps us to separate out data in the web page and we can create a particular section for particular data or function in the web pages.

Can you put a heading in a div?

Use div in Web LayoutsYou can put together the header, nav, sections, and footer of a page in an individual div tag so they can be styled together. Later in this tutorial, I will take you through how to make a web layout with multiple div tags without getting confused.

How do I fix a div header?

Answer: Use CSS fixed positioning You can easily create sticky or fixed header and footer using the CSS fixed positioning. Simply apply the CSS position property with the value fixed in combination with the top and bottom property to place the element on the top or bottom of the viewport accordingly.

How do you make a div inside a div in HTML?

To start, wrap a div element in another div element in your HTML. Give the inner div a class name like "child" and the outer div a class name like "parent." Then in your CSS, use the class selector .parent to style the outer div. Set its height, width, and background color.


2 Answers

HTML:

<div class="box">
    <h2>Div Title</h2>
    <p>Div content.</p>
</div>

and the CSS:

.box {border:2px solid #0094ff;}
.box h2 {background:#0094ff;color:white;padding:10px;}
.box p {color:#333;padding:10px;}

Use CSS3 for border radius

.box {
    -moz-border-radius-topright:5px;
    -moz-border-radius-topleft:5px;
    -webkit-border-top-right-radius:5px;
    -webkit-border-top-left-radius:5px;
    border-top-left-radius:5px;
    border-top-right-radius:5px;
}

The above code will work in firefox, safari, chrome, opera (10.5 +) etc

Now with bonus demo

like image 159
wiifm Avatar answered Nov 04 '22 14:11

wiifm


HTML:

<div class="myDiv">
  <h2>Div Title</h2>
  <p>Div content.</p>
</div>

CSS:

.myDiv {
  border:2px solid #0094ff;
  -webkit-border-top-left-radius:6px;
  -webkit-border-top-right-radius:6px;
  -moz-border-radius-topleft:6px;
  -moz-border-radius-topright:6px;
  border-top-left-radius:6px;
  border-top-right-radius:6px;
  width:300px;
  font-size:12pt; /* or whatever */
}
.myDiv h2 {
  padding:4px;
  color:#fff;
  margin:0;
  background-color:#0094ff;
  font-size:12pt; /* or whatever */
}
.myDiv p {
  padding:4px; 
}

Demo.

like image 26
ЯegDwight Avatar answered Nov 04 '22 14:11

ЯegDwight