Reply
Margin tag
Old 04-24-2007, 04:30 PM Margin tag
Skilled Talker

Posts: 84
Could some tell me how this code centers something, ie this header.

Code: margin: 0 auto;

I don't understand why this would center my image.
thanks for any help.
__________________
www.nelcode.co.uk
afcbob is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 04-24-2007, 04:58 PM Re: Margin tag
ADAM Web Design's Avatar
Canadastaninianite

Posts: 5,945
Name: Adam for web page design, not program
Location: Toronto, Ontario, Canada
It works in conjunction with a width property (by the way, margin is a property too.) 0 refers to the top and bottom margins (so there are no margins above or below your element) and auto refers to the left-right margins (50% of the remaining space goes to the left of the element, and 50% to the right of the element.)

For example:
Code:
margin:  0px auto;
width:  50%;
means that the element will be 50% of the width of its container, with 25% margins on the left and right sides.
ADAM Web Design is offline
Reply With Quote
View Public Profile Visit ADAM Web Design's homepage!
 
Old 04-24-2007, 06:03 PM Re: Margin tag
Skilled Talker

Posts: 84
Thanks for that.
__________________
www.nelcode.co.uk
afcbob is offline
Reply With Quote
View Public Profile
 
Old 04-25-2007, 04:44 AM Re: Margin tag
Skilled Talker

Posts: 84
OK would the hole thing to site in the middle of the screen but tried this

Code:
margin:  auto auto;
width: 600px;
height: 300px;
What i'm i doing wrong.
__________________
www.nelcode.co.uk
afcbob is offline
Reply With Quote
View Public Profile
 
Old 04-25-2007, 05:15 AM Re: Margin tag
chrishirst's Avatar
Super Moderator

Posts: 13,622
Location: Blackpool. UK
Quote:
What i'm i doing wrong.
Nothing, it just won't work at all

BTW what's a margin tag?
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-25-2007, 05:27 AM Re: Margin tag
Skilled Talker

Posts: 84
Would it not be best to put why it would not work.

Margin tag is for creating a margin around a item.
__________________
www.nelcode.co.uk
afcbob is offline
Reply With Quote
View Public Profile
 
Old 04-25-2007, 06:37 AM Re: Margin tag
chrishirst's Avatar
Super Moderator

Posts: 13,622
Location: Blackpool. UK
It won't work because you can't apply an auto value for the top and bottom margins.

Quote:
Margin tag is for creating a margin around a item
No it isn't. There is no such thing as a margin tag.
It is either;

an attribute of a visual HTML element tag

or

A CSS property of a style that can be applied to visual HTML elements
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-25-2007, 08:27 AM Re: Margin tag
Skilled Talker

Posts: 84
Ok thank you will try something else to get it right.
__________________
www.nelcode.co.uk
afcbob is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Margin tag
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14046 seconds with 12 queries