Warrior Forum - The #1 Digital Marketing Forum & Marketplace

Warrior Forum - The #1 Digital Marketing Forum & Marketplace (https://www.warriorforum.com/)
-   Programming (https://www.warriorforum.com/programming/)
-   -   Adding javascript to my <head> tags is adding a margin... why? (https://www.warriorforum.com/programming/210419-adding-javascript-my-head-tags-adding-margin-why.html)

MarcMilburn 8th May 2010 09:42 AM

Adding javascript to my <head> tags is adding a margin... why?
 
Hi everyone,

I have a minisite design which requires no margins at the top, in order to work with the background image (which repeats).

I also need to add in some javascript which requires 5 lines in the <head></head> section... BUT when I insert it in, it adds a random line above the minisite design.

All of the CSS margins are set to 0.

Anyone know why?

HELP! lol

Thanks,
- Marc

ninal 8th May 2010 09:51 AM

Re: Adding javascript to my <head> tags is adding a margin... why?
 
Could you provide a link to your site? Maybe you just forgot to close the tags? It's pretty hard to tell without the source code. You can also post your source code if you prefer

MarcMilburn 8th May 2010 10:01 AM

Re: Adding javascript to my <head> tags is adding a margin... why?
 
<html>
<head>
<title>Coaching Time!</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript">
function showIt() {
document.getElementById("hid").style.visibility = "visible";
}
setTimeout("showIt()", 1546000); // 1000 = 1 sec
</script>
</head>
<body>
<div class="wrapper">
<div class="header"></div>
<div class="copy">
</div>
<div class="footer"></div>
</div>
</body>
</html>

MarcMilburn 8th May 2010 10:03 AM

Re: Adding javascript to my <head> tags is adding a margin... why?
 
Oh and this is taken from the CSS file...

body{
margin:0;
margin-top:0;
text-align:center;
color:#1a1a1a;
background:#2f2f2f url(/images/bg.jpg) repeat-x;
}

webtrix 8th May 2010 11:12 AM

Re: Adding javascript to my <head> tags is adding a margin... why?
 
Quote:

Originally Posted by MilburnMarketing (Post 2075559)
<html>
<head>
<title>Coaching Time!</title>
<link rel="stylesheet" href="style.css" type="text/css">
<script type="text/javascript">
function showIt() {
document.getElementById("hid").style.visibility = "visible";
}
setTimeout("showIt()", 1546000); // 1000 = 1 sec
</script>
</head>
<body>
<div class="wrapper">
<div class="header"></div>
<div class="copy">
</div>
<div class="footer"></div>
</div>
</body>
</html>

Save this as a page and see if there is a line...

Also margin-top:0; is sufficient here..

MarcMilburn 8th May 2010 11:20 AM

Re: Adding javascript to my <head> tags is adding a margin... why?
 
WebTrix...

No, there was no margin there. So I tried replacing my <head></head> section with yours and its FIXED!

Thank you soo much!!

I LOVE this place :D


All times are GMT -6. The time now is 09:45 AM.