Jump to content

how to align DIV tag centrally without distrubing horizantal alignment


shah

Recommended Posts

Hi,

I have a little problem here. When i try to central align div tag witin a page using STYLE

margin:0 auto; 

it automatically puts some vertical pixels. for example if i put a div within a div tag, and use the above code, it will central align it horizontally but will leave some vertical margin before it starts the new div tag.

 

shortly when ever i use the

.header {
height: 101px;
width: 842px;
background-color: #F33;
}

it will align the header horizontally but it will always leave some vertical space  (that is top:0 or margin-top:0) will not work whatever i do. kindly help me regarding this problem.

 

BR

Syed Arif Ullah Shah

 

 

Link to comment
Share on other sites

Well, in my stylesheets, I tend to first wipe out all margins, padding and borders with this declaration:

 

html,body,div,div *{margin:0;padding:0;border:0}

 

It has made a difference for me in site construction. Without it, I have had small display issues, and with it added, it fixed it. Try adding that snippet to your stylesheets and see if that helps.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.