Solved

margin-top: 0px; - Not working??

Posted on 2009-05-14
4
847 Views
Last Modified: 2012-05-07
I have CSS code that is supposed to have the top row of a table up against the top of the browser, but there is still a space above the table.  What am I doing wrong??
body {
	font-family: Arial, Helvetica, sans-serif;
	margin-top: 0px;	
	margin-bottom: 0px;
	margin-left: 0px;
	margin-right: 0px;
}
 
   #submenustyle {
      margin: 0 auto;
      text-align: left;
	  height: 30px;
      vertical-align: middle;
   }
 
 
 
.menulinks {
    font-family: Arial, Helvetica, sans-serif;
	font-size: 14px;
	font-weight: bold;
	color: #4169E1;
	vertical-align: top;
 
}
 
a.menulinks {
    font-family: Arial, Helvetica, sans-serif;
	font-size: 14px;
	font-weight: bold;
	color: #4169E1;
	vertical-align: top;
	text-decoration:none;
 
}
 
a.menulinks:hover {  
    font-family: Arial, Helvetica, sans-serif;
	font-size: 14px;
	font-weight: bold;
	color: #00008B;
	vertical-align: top;
	text-decoration:none;
 
}
 
 
.maintext {
    font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #000000;
	vertical-align: top;
			
 
}
 
a.maintext {
        font-family: Arial, Helvetica, sans-serif;
        text-decoration:none;
        font-size: 10px;
		color: #000000;
 
 
}
 
a.maintext:hover {  font-family: Arial, Helvetica, sans-serif;
	font-size: 10px;
	color: #012315;
	background-color: #FDC844;
 
 
}
 
 
 
 
 
.subtopictext {
        font-family: Arial, Helvetica, sans-serif;
	font-size: 18px;
	color: #7b7b7b;
}  
 
div#main h1 {
	margin:10px 0 0 7px;
	padding:0;
	width:98%;
	text-align:left;
	font-size:25px;
	color:#333;
	border-bottom:1px dotted #012315;
	font-weight:normal;
}
 
////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
 
<body>
 
 
<table width="800" border="0" align="center">
  <tr>
    <td><!-- Header Bar -->
	<img src="images/footerline.jpg" />
	</td>
  </tr>
  <tr>
    <td><!-- Logo/ Top Level Menu Row -->
			<table width="800" border="0" cellpadding="0" cellspacing="0">
  				<tr>
    				<td width="200"><!-- Logo -->
					Insert Logo Here
					</td>
   					<td width="600"><!-- Top Level Menu -->
					<img src="images/link.jpg"
					 /><img src="images/link.jpg"
					 /><img src="images/link.jpg"
					 /><img src="images/link.jpg"
					 /><img src="images/link.jpg"
					 /><img src="images/link.jpg"
					 /></td>
  				</tr>
			</table>
	</td>
  </tr>
......

Open in new window

0
Comment
Question by:tru504187211
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 12

Accepted Solution

by:
Chad Haney earned 500 total points
ID: 24392210
Border Collapse is part of your problem.

Add the style to the table(s) of:
border-collapse:collapse;

And also you will want to add the [cellpadding="0" cellspacing="0"] to the top table.

Recommend using the Firefox add-on of Web Developer and you can see the table outlines (outline>table>cells).
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<style type="text/css">
body {
        font-family: Arial, Helvetica, sans-serif;
        margin:0px;
}
table{
	border-collapse:collapse;
 
}
 
   #submenustyle {
      margin: 0 auto;
      text-align: left;
          height: 30px;
      vertical-align: middle;
   }
 
 
 
.menulinks {
    font-family: Arial, Helvetica, sans-serif;
        font-size: 14px;
        font-weight: bold;
        color: #4169E1;
        vertical-align: top;
 
}
 
a.menulinks {
    font-family: Arial, Helvetica, sans-serif;
        font-size: 14px;
        font-weight: bold;
        color: #4169E1;
        vertical-align: top;
        text-decoration:none;
 
}
 
a.menulinks:hover {  
    font-family: Arial, Helvetica, sans-serif;
        font-size: 14px;
        font-weight: bold;
        color: #00008B;
        vertical-align: top;
        text-decoration:none;
 
}
 
 
.maintext {
    font-family: Arial, Helvetica, sans-serif;
        font-size: 10px;
        color: #000000;
        vertical-align: top;
                        
 
}
 
a.maintext {
        font-family: Arial, Helvetica, sans-serif;
        text-decoration:none;
        font-size: 10px;
                color: #000000;
 
 
}
 
a.maintext:hover {  font-family: Arial, Helvetica, sans-serif;
        font-size: 10px;
        color: #012315;
        background-color: #FDC844;
 
 
}
 
 
 
 
 
.subtopictext {
        font-family: Arial, Helvetica, sans-serif;
        font-size: 18px;
        color: #7b7b7b;
}  
 
div#main h1 {
        margin:10px 0 0 7px;
        padding:0;
        width:98%;
        text-align:left;
        font-size:25px;
        color:#333;
        border-bottom:1px dotted #012315;
        font-weight:normal;
}
 
</style>
</head>
 
<body>
 
 
<table width="800" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><!-- Header Bar -->
        <img src="images/footerline.jpg" />
        </td>
  </tr>
  <tr>
    <td><!-- Logo/ Top Level Menu Row -->
                        <table width="800" border="0" cellpadding="0" cellspacing="0">
                                <tr>
                                <td width="200"><!-- Logo -->
                                        Insert Logo Here
                                        </td>
                                        <td width="600"><!-- Top Level Menu -->
                                        <img src="images/link.jpg"
                                         /><img src="images/link.jpg"
                                         /><img src="images/link.jpg"
                                         /><img src="images/link.jpg"
                                         /><img src="images/link.jpg"
                                         /><img src="images/link.jpg"
                                         /></td>
                                </tr>
                        </table>
        </td>
  </tr>
</table>
</body>
</html>

Open in new window

0
 
LVL 19

Expert Comment

by:erikTsomik
ID: 24392238
what browser are you on. I am on the IE7 and it works just fine for me
0
 
LVL 12

Expert Comment

by:Chad Haney
ID: 24494455
Did the border-collapse resolve your issue?  If not please provide further information so we can assist you.
0
 

Author Closing Comment

by:tru504187211
ID: 31581784
Yes, this solution worked.

THANKS!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing CSS, there are a few simple rules that will make your life easier.    1. Using ‘* {box-sizing:border-box;}’. Using this will wrap all your elements in a nice little compact box-model that will give you the width you want, like so... …
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question