Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Do I need more in my external stylesheet? 1

Status
Not open for further replies.

okpeery

Instructor
Dec 29, 2005
102
US
I have been working from a template and modifying it substantially. I currently have all the CSS I've modified in the head section. I did this because the maker of the template specified that you couldn't modify their javascript or their CSS. Their CSS is all custom classes I think. I put my modifications in the head and it looks great. I thought I'd just create a 2nd style sheet rather than have all the CSS in the head. When I did this I lost all styles. I've never used 2 stylesheets before. Maybe I didn't include enough. It looks just how I want it to with CSS in the head. How can I get it to work correctly with a 2nd style sheet?

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"[URL unfurl="true"]http://www.w3.org/TR/html4/strict.dtd">[/URL]

<html>

<head>
	<title>Owen Peery Resume</title>
		<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
		<meta name="generator" content="HAPedit 3.1">
			<style type="text/css">
				body{padding: 20px;background-color: #B0BFC2; text-align: center;
    			font: 100% Verdana,Arial,sans-serif}

				h1,h2,p{margin: 0;padding: 0 10px 0.4em}

				h1{font-size: 250%;color: #FFF;letter-spacing: 1px}

				h2{font-size: 150%;color: #FFF}

				div#container{width:700px;margin: 0 left;text-align:left}

				div#content{float:right;width:515px;background: #BBDB88;}

				div#nav{float:left;width:180px;margin-top:30px;background: #FACD8A;}
				
				#nav ul
        		{
        		margin: 5px;
        		padding: 0;
        		list-style-type: none;
        		text-align: right;
        		line-height: 250%;
        		}
        		
				a
        		{
        		text-decoration: none;
        		}
        		
        		a:link
        		{
        		color: black;
        		}
        		
        		a:visited
        		{
        		color: #555555;
        		}
        		
        		a:hover
        		{
        		color: orange;
        		}
</style>

<link rel="stylesheet" type="text/css" href="niftyCorners.css">
<link rel="stylesheet" type="text/css" href="niftyPrint.css" media="print">
<link rel="stylesheet" type="text/css" href="resume2/resumestyle.css">

<script type="text/javascript" src="nifty.js"></script>
<script type="text/javascript">
window.onload=function(){
if(!NiftyCheck())
    return;
Rounded("div#content","all","#B0BFC2","#BBDB88","smooth");
Rounded("div#nav","tl bl","#B0BFC2","#FACD8A","smooth");
}
</script>

</head>

<body>
	<div id="container">
		<div id="nav">
			<p>
				<ul>
        			<li><a href="index.html">Home</a></li>
        			<li><a href="education.html">Education</a></li>
        			<li><a href="workexperience.html">Work Experience</a></li>
        			<li><a href="relatedexperience.html">Related Experience</a></li>
        			<li><a href="technologyskills.html">Technology Skills</a></li>
        		</ul>
			</p>
		</div>
	<div id="content">
	<h1>Owen Peery</h1><br>
		
	
	<h2>Contact Information</h2>
	
		<p>
			336 E. Gowen Ave<br>
			Philadelphia, PA 19119<br>
			215.313.6097<br>
			okpeery@earthlink.net<br>
		</p><br><br>

	<h2>Objective</h2>
	
		<p>
				To secure a technology teaching job beginning in the 2006 school year, in an 
        		academically challenging k-12 environment, that also focuses on social 
        		and emotional development.
		</p>
	
	</div>
</div>

</body>

</html>

This is the stylesheet where I took the styles out of the head
Code:
				body
					{
					padding: 20px;
					background-color: #B0BFC2;
					text-align: center;
    				font: 100% Verdana,Arial,sans-serif;
    				}

				
				h1,h2,p
					{
					margin: 0;
					padding: 0 10px 0.4em;
					}

				h1
					{
					font-size: 250%;
					color: #FFF;
					letter-spacing: 1px;
					}

				h2
					{
					font-size: 150%;
					color: #FFF;
					}

				div#container
					{
					width:700px;
					margin: 0 left;
					text-align:left;
					}

				div#content
					{
					float:right;
					width:515px;
					background: #BBDB88;
					}

				div#nav
					{
					float:left;
					width:180px;
					margin-top:30px;
					background: #FACD8A;
					}
				
				#nav ul
        			{
        			margin: 5px;
        			padding: 0;
        			list-style-type: none;
        			text-align: right;
        			line-height: 250%;
        			}
        		
				a
        			{
        			text-decoration: none;
        			}
        		
        		a:link
        			{
        			color: black;
        			}
        		
        		a:visited
        			{
        			color: #555555;
        			}
        		
        		a:hover
        			{
        			color: orange;
        			}
</style>

Any ideas?
 
Do you have style tags in the external stylesheet? If you do, then the styles will not work, because only css is permitted in the external stylesheet.
 
I removed my html and it still didn't work. I figured it out though, which lead me to another question . . .

When you use an image in an html doc you must use the relative url ie images/bag.jpg

I thought the naming convention for css was the same so I linked it using resume2/resumestyle.css. As soon as I got rid of the resume2/ the styles appeared.

How does it know where the stylesheet is? Why do you have to put the relative url for images in html when you don't for css? If it is really complicated forget about it but I keep making the same mistake and if I understood why I might keep it straight.
 
You always have to put the relative URL for images and CSS, if you dont have a somthing/ infront of your file.css then it asumes the .css is in the same folder as the .htm file.

So if you keep your .css files in a subfolder called 'resume2' then the link ref 'resume2/resumestyle.css' would be correct, but from the sounds of things you have your .css files in the same folder as the .htm, so just 'resumestyle.css' is sufficient, whereas your images are in a sub-folder called 'images'.

Hope that helps explain it.

My personal preferance is that ALL css should be in an external file, unless it is only relevant to 1 particular page. if the style is going to be used multiple times then always put it in an external file, that way it stops you having to duplicate code, and if you decide to change a style you dont have to change it in several locations.

Rob
 
That clears it up for me. Of course it makes sense now, where were you last night at 4:15 AM when I needed you?
 
lol ... on the old 'Late Burn' Eh?

Good man .... my best work is always done in the darker hours of the night, just as the birds start waking up lol.

I'm new to all this HTMl and CSS stuff myself, it doesnt take long to learn though, give it a few weeks of hand coding and you'll know plenty.

Rob

p.s. thanks for the purple star.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top