[thelist] Stupid CSS question

Simon Willison simon at incutio.com
Thu Aug 1 04:17:00 CDT 2002

At 12:52 01/08/2002 +0530, Madhu Menon wrote:
>At 12:43 PM 01-08-02, Shashank Tripathi wrote:
>>Off the top, I guess "margin-top: 0px" in the style should do what you want.
>Well, I tried that, but it works only when you style the H2 with it. Can't
>I just apply something to the DIV instead?

Unless you want to mess around with negative margins (which can be
considered a bit of a hack) you are better off styling the h2. however,
proper use of selectors can allow you to style only the h2 within that
particular <div>:

<style type="text/css">
div#myDiv {
   border: #C00 1px dotted;
   padding: 0px 10px 0px 10px;
   background-color: #EED;
div#myDiv h2 {
   margin-top: 0px;

<div id="myDiv">

<h2>Headline goes here</h2>

<p>Some text</p>



Simon Willison


More information about the thelist mailing list