I am using Dreamweaver CS3 and have built quite a few (basic) websites previously so not a complete novice but am totally thrown by my CSS not rendering properly in a new website I am building.
I have set up a new template, all working fine, full CSS included, previewing in browser ok.
Then created 2 new pages from this template 'Aug.html' and 'Oct.html' and saved both - both pages contain a link to each other and both preview fine in the browser on their own.
However when I click on the either link from either page, doesn't matter which page I start with, the result is the same, the new page that opens seems to forget half the CSS, div's completely move and links are reverted back to blue and underlined, everything is changed as if there is no CSS at all.
Why does the CSS not work here? I have never had this problem before, the CSS is simple, I have about 6 div's to contain everything in, including a #wrapper. body tags and a:links all preview fine until I click and the new page that opens up looses its CSS. There are no accessibility / compatibility issues coming up either.
Please help - have tried so many different things now I am totally lost! I know it must be simple but I really can't find an obvious reason why, really need help with this.
Thanks....
thanks very much for your reply but I have just this second found a solution via another forum with someone who had similar problem, it read: 'delete the link from your HTML file, then add all the CSS within your stylesheet between <style></style> tags in the head of your document, see if that works.'
I've never done this before, perhaps I should have been doing so? But anyway copying and pasting all my CSS in between the style tags in the head of my template has fixed the problem. Slightly concerned that if I make further changes to my CSS this now means that I will have to remember to copy and paste the info into here each time as well? Anyway fixed for now ![]()
unfortunately it's not online yet - am in the process of trying to update a website so only the current old version is live... as I have made changes to the template I no longer have it as it originally was when causing problems - however here is the current version copied and pasted below. Thanks again for the response though, it is a bit worrying that I couldn't get this to work properly as it should be simple with CSS - anyway here's the template.html code if this helps:
<!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=UTF-8" />
<!-- TemplateBeginEditable name="doctitle" -->
<title>London Gigs - Gigs and Live Music in London</title>
<!-- TemplateEndEditable -->
<link href="/2012LG_CSS.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
<!--
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
</script>
<style type="text/css">
<!--
.style1 {font-size: 14px}
.style2 {color: #CC0000}
body {
background-image: url(../_Images/_ADs/1252.jpg);
background-repeat: repeat;
}
-->
@charset "UTF-8";
#wrapper {
width: 1010px;
margin: auto;
background-color: #FFFFFF;
}
#banner {
height: 62px;
width: 973px;
padding-top: 4px;
padding-bottom: 1px;
padding-left: 37px;
background-color: #FFFFFF;
}
#logo {
width: 1010px;
background-color: #FFFFFF;
}
#content {
float: left;
width: 705px;
padding-right: 15px;
padding-left: 45px;
background-color: #FFFFFF;
clear: left;
}
#right {
float: right;
width: 205px;
margin-right: 35px;
background-color: #FFFFFF;
clear: none;
}
#footer {
clear: both;
float: none;
width: 1010px;
background-color: #FFFFFF;
}
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
line-height: 17px;
text-decoration: none;
margin: 0px;
}
a:link {
font-weight: bold;
color: #1b1464;
text-decoration: none;
}
a:visited {
font-weight: bold;
color: #1b1464;
text-decoration: none;
}
a:hover {
font-weight: bold;
color: #0654a6;
text-decoration: none;
}
</style>
<!-- TemplateBeginEditable name="head" --><!-- TemplateEndEditable -->
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-9870079-10']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body onload="MM_preloadImages('../_Images/NavHome-on.jpg','../_Images/NavG igs-on.jpg','../_Images/NavVenues-on.jpg','../_Images/NavLinks-on.jpg' ,'../_Images/NavContact-on.jpg','../_Images/NavJan-on.jpg','../_Images /NavFeb-on.jpg','../_Images/NavMar-on.jpg','../_Images/NavApr-on.jpg', '../_Images/NavMay-on.jpg','../_Images/NavJun-on.jpg','../_Images/NavJ ul-on.jpg','../_Images/NavAug-on.jpg','../_Images/NavSep-on.jpg','../_ Images/NavOct-on.jpg','../_Images/NavNov-on.jpg','../_Images/NavDec-on .jpg','../_Images/_ADs/ATP_Banner3.jpg','../_Images/_ADs/Cune_Banner2. jpg','../_Images/Collab_Organ.jpg','../_Images/Collab_Nemesis.jpg','.. /_Images/Collab_Descissor.jpg','../_Images/Facebook.jpg','../_Images/T witter.jpg','../_Images/Nav2013-on.jpg')">
<div id="wrapper">
<div id="banner"><a name="top" id="top"></a><a href="http://www.atpfestival.com/events/shellacxmas.php" target="_blank" onmouseover="MM_swapImage('Image38','','../_Images/_ADs/ATP_Banner3.j pg',1)" onmouseout="MM_swapImgRestore()"><img src="../_Images/_ADs/ATP_Banner3.jpg" alt="ATP" name="Image38" width="464" height="60" border="0" id="Image38" /></a><img src="../_Images/_ADs/Top_Spacer.jpg" width="4" height="23" /><a href="http://www.cuneiformrecords.com/" target="_blank" onmouseover="MM_swapImage('Image39','','../_Images/_ADs/Cune_Banner2. jpg',1)" onmouseout="MM_swapImgRestore()"><img src="../_Images/_ADs/Cune_Banner2.jpg" alt="Cuneiform Records" name="Image39" width="464" height="60" border="0" id="Image39" /></a></div>
<div id="logo"><img src="../_Images/LondonGigs5.jpg" alt="london gigs" width="805" height="153" align="left" />Collaborators:<br />
<a href="http://www.organart.com/" target="_blank" onmouseover="MM_swapImage('Image40','','../_Images/Collab_Organ.jpg', 1)" onmouseout="MM_swapImgRestore()"><img src="../_Images/Collab_Organ.jpg" alt="Organ" name="Image40" width="42" height="42" border="0" id="Image40" /></a><a href="http://www.nemesis.to/go.htm" target="_blank" onmouseover="MM_swapImage('Image41','','../_Images/Collab_Nemesis.jpg ',1)" onmouseout="MM_swapImgRestore()"><img src="../_Images/Collab_Nemesis.jpg" alt="Nemesis To Go" name="Image41" width="42" height="42" border="0" id="Image41" /></a><a href="http://doubledgescissor.wordpress.com/" target="_blank" onmouseover="MM_swapImage('Image42','','../_Images/Collab_Descissor.j pg',1)" onmouseout="MM_swapImgRestore()"><img src="../_Images/Collab_Descissor.jpg" alt="des" name="Image42" width="42" height="42" border="0" id="Image42" /></a><br />
<br />
<a href="https://www.facebook.com/LondonGigs" target="_blank" onmouseover="MM_swapImage('Image43','','../_Images/Facebook.jpg',1)" onmouseout="MM_swapImgRestore()"><img src="../_Images/Facebook.jpg" alt="facebook" name="Image43" width="28" height="28" border="0" id="Image43" /></a><img src="../_Images/_ADs/Top_Spacer.jpg" alt="p" width="4" height="23" /><a href="http://twitter.com/london_gigs_" target="_blank" onmouseover="MM_swapImage('Image44','','../_Images/Twitter.jpg',1)" onmouseout="MM_swapImgRestore()"><img src="../_Images/Twitter.jpg" alt="twitter" name="Image44" width="30" height="28" border="0" id="Image44" /></a><br />
<br />
<br />
<br />
<img src="../_Images/NavSpacer2.jpg" width="254" height="24" /><!-- TemplateBeginEditable name="EditRegion4" --><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image33','','../_Images/NavHome-on.jpg',1) "><img src="../_Images/NavHome.jpg" alt="Home" name="Image33" width="65" height="31" border="0" id="Image33" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image34','','../_Images/NavGigs-on.jpg',1) "><img src="../_Images/NavGigs.jpg" alt="Gigs" name="Image34" width="53" height="32" border="0" id="Image34" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image35','','../_Images/NavVenues-on.jpg', 1)"><img src="../_Images/NavVenues.jpg" alt="Venues" name="Image35" width="85" height="31" border="0" id="Image35" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image36','','../_Images/NavLinks-on.jpg',1 )"><img src="../_Images/NavLinks.jpg" alt="Links" name="Image36" width="65" height="32" border="0" id="Image36" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image37','','../_Images/NavContact-on.jpg' ,1)"><img src="../_Images/NavContact.jpg" alt="Contact" name="Image37" width="96" height="32" border="0" id="Image37" /></a><!-- TemplateEndEditable --><br />
<br />
<br />
</div>
<div id="content"><!-- TemplateBeginEditable name="EditRegion3" --><strong><img src="../_Images/Nav2012-on.jpg" width="48" height="25" /><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image45','','../_Images/Nav2013-on.jpg',1) "><img src="../_Images/Nav2013.jpg" alt="2013" name="Image45" width="50" height="25" border="0" id="Image45" /></a><br />
<a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image21','','../_Images/NavJan-on.jpg',1)" ><img src="../_Images/NavJan.jpg" alt="Jan" name="Image21" width="41" height="28" border="0" id="Image21" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image22','','../_Images/NavFeb-on.jpg',1)" ><img src="../_Images/NavFeb.jpg" alt="Feb" name="Image22" width="42" height="28" border="0" id="Image22" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image23','','../_Images/NavMar-on.jpg',1)" ><img src="../_Images/NavMar.jpg" alt="Mar" name="Image23" width="51" height="28" border="0" id="Image23" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image24','','../_Images/NavApr-on.jpg',1)" ><img src="../_Images/NavApr.jpg" alt="Apr" name="Image24" width="48" height="27" border="0" id="Image24" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image25','','../_Images/NavMay-on.jpg',1)" ><img src="../_Images/NavMay.jpg" alt="May" name="Image25" width="48" height="28" border="0" id="Image25" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image26','','../_Images/NavJun-on.jpg',1)" ><img src="../_Images/NavJun.jpg" alt="Jun" name="Image26" width="43" height="28" border="0" id="Image26" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image27','','../_Images/NavJul-on.jpg',1)" ><img src="../_Images/NavJul.jpg" alt="Jul" name="Image27" width="41" height="28" border="0" id="Image27" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image28','','../_Images/NavAug-on.jpg',1)" ><img src="../_Images/NavAug.jpg" alt="Aug" name="Image28" width="48" height="28" border="0" id="Image28" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image29','','../_Images/NavSep-on.jpg',1)" ><img src="../_Images/NavSep.jpg" alt="Sep" name="Image29" width="43" height="28" border="0" id="Image29" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image30','','../_Images/NavOct-on.jpg',1)" ><img src="../_Images/NavOct.jpg" alt="Oct" name="Image30" width="46" height="26" border="0" id="Image30" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image31','','../_Images/NavNov-on.jpg',1)" ><img src="../_Images/NavNov.jpg" alt="Nov" name="Image31" width="43" height="27" border="0" id="Image31" /></a><a href="#" onmouseout="MM_swapImgRestore()" onmouseover="MM_swapImage('Image32','','../_Images/NavDec-on.jpg',1)" ><img src="../_Images/NavDec.jpg" alt="Dec" name="Image32" width="49" height="28" border="0" id="Image32" /></a><br />
<br />
<br />
<br />
</strong>content<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<!-- TemplateEndEditable --></div>
<div id="right"><img src="../_Images/_ADs/ADGigDead&Buried_31Aug.jpg" width="200" height="300" /><br />
<br />
<br />
<br />
<br />
<br />
<br />
</div>
<div id="footer">
<div align="center">© LONDON GIGS LondonGigs.net 2009 - Last updated on 08/19/2012 - Web Design: <a href="http://www.evhdesign.co.uk/" target="_blank">EVHDesign</a><br />
<br />
</div>
</div>
</div>
</body>
</html>
However when I click on the either link from either page, doesn't matter which page I start with, the result is the same, the new page that opens seems to forget half the CSS, div's completely move and links are reverted back to blue and underlined, everything is changed as if there is no CSS at all.
You must be referring to what happens when you PREVIEW a page in DW, is that correct? In other words, you preview page A, click the link to page B, and page B appears without the CSS - correct? Here's why -
<link href="/2012LG_CSS.css" rel="stylesheet" type="text/css" />
Your link to the stylesheet is a ROOT relative link (see the leading "/"?). When page B loads after clicking on the link in page A, it tells the browser to find the stylesheet at "C:/2012LG_CSS.css" because the browser has NO idea where the root of the DW site is and assumes that the root reference in the link refers to the root of the hard drive. Normally, one would not use root relative links unless one had a good reason to do so - in your case, I'm confident you do not. Change that link to a document relative one, i.e.,
<link href="../2012LG_CSS.css" rel="stylesheet" type="text/css" />
and things will work much better.
Generally speaking, it's not a good idea to click away from any previewed page when using DW.
yes! this is exactly right, thank you very much... now i've remembered how I originally saved my new CSS and for some reason I did so as a root relative link as you pointed out, so will make sure I don't do this again. I've now removed the CSS from the style tags in the head of my template (the original 'fix') and updated the CSS link as suggested (../) and all is working just fine. For info the full site is updated and now live at: www.londongigs.net - Thanks so much for the help, it's great to know what the real problem was, much appreciated.
North America
Europe, Middle East and Africa
Asia Pacific