Jump to content

Margin with Tables-Need help


Terrorer

Recommended Posts

I am new to CSS and HTML really and I have been reading the tutorials for a week now. So I am making this website, just on my G drive though, as I am not paying for a server. It's really just a table right now, with a title picture and some links to the other pages, an Iframe for my little slideshow and some color here and there. I have a style sheet, and I sort of get it really, but most things that happened on it were trial and error stuff (the ordering on that thing confuses me so much). My problem though, is that i want my table, of my website, to have a margin, so it's in the middle. How do I give it one? I've been trying for a bit now but nothing really works. I really just don't know where to put it. I can put the margin as a class or id, but I have no clue where to put it on my style sheet or the web pages.

Link to comment
Share on other sites

Lets do something just a little different to help you understand what's going on. I'm going to use a <div>, you can change it to a proper <table> if you want but I'm using <div> for simplicity's sake.

<div id="box"></div>

And you can center your <div> by using margins such as I'm doing below. I added width, height and borders so you can see the <div> as a rectangle otherwise you wouldn't be able to see it. Also if you want to be able to center an object it has to have a width smaller than whatever it's in but it does have to have a width or else you'll get crazy results.

#box {  width: 300px;  height: 200px;  border: 1px solid black;  margin: 0 auto;}

I used pixels (px) here but you can use percentages (%) so if anyone makes the window smaller, it gets smaller too.

Link to comment
Share on other sites

See, I don't understand Div, not yet really, but I just forgot about my external style sheet and did it individually for each page. Worked that way, but I think it's because my style sheet is really unorganized, and I have no clue where to put things. Thanks though. :3

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...