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!

BODY IN STYLE SHEET NOT WORKING

Status
Not open for further replies.

autoIT

IS-IT--Management
May 10, 2006
68
US
I am having problems with the following code when I'm doing an internal link

body {color: black; background: teal; font-family:arial}

on another open HTML Document I have this code


<BODY>

This is a test!

</BODY>

I should be seeing a teal bacground with white lettering and I don't.........HELP
 
Actually you'd be seeing black type. How did you link the style to the document? Code available with CSS?
 
It's probably a case sensitivity issue


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
even still with the type whatever color, the background should still come through.

<link rel="styleshhet" type="text/css" href="external.htm">

the document that contains the instruction and the document pulling from that instruction are both located on the same machine.


when you say case sensitivity issue do you mean for example:

body {color: black:.....

vs.

<BODY>
 
Yes, I mean that body does not equal BODY


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
Do any of these pages have a URL that we can look at? The snippets you've shown us are mostly OK, but the problem's probably in the bits you haven't given us.

Code:
<link rel="[red]styleshhet[/red]" type="text/css" href="external.htm">
That should be [tt]stylesheet[/tt], but maybe that's only a typo on here. It's also a bad idea to give your stylesheets a .htm extension - the web server will probably send it with a MIME type of text/html, and it's not an HTML document, it's a CSS one. Having the wrong type will make Firefox (at least) ignore it. Call your stylesheet [tt]external.css[/tt] instead.

Also, have you included [tt]<style>[/tt] tags in your external CSS file? Don't. That's HTML syntax, and it isn't an HTML document.

I think case sensitivity only comes into play if the document is declared as XHTML. I think it makes sense, though, to get into the habit of having a single case convention and sticking to it everywhere. I've wasted many hours debugging situations where I've said [tt]foobar[/tt] in one place and [tt]Foobar[/tt] in another and not spotted the difference.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
twas a typo here. I've changed it to a css file, it's easier to code like that anyway. I agree with you about sticking to one case as well, longer codes can be cumbersum to read if case goes back and forth. I just tried it after resaving as a .css and it still is having problems but i will continue to debug. If you have anymore suggestions please let me know.
 
i did use:

<style type="text/css>

because I thought it was needed
 
ChrisHunt said:
Do any of these pages have a URL that we can look at? The snippets you've shown us are mostly OK, but the problem's probably in the bits you haven't given us.
As Chris says above, this isn't easy for us unless you give us a URL to your page or the contents of your HTML and CSS files.


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
twas a typo here.

So what else in the code you gave us was a typo? Come on - give us the real deal, not what you think might possibly be somewhat related to the real deal. You want real help, then give us real code.

i did use:

<style type="text/css>

In your external CSS file? If so, you should remove it, as it will cause problems. External CSS files should NOT have this in.

You should also make sure if you have any HTML-style or single-line C style comments:

Code:
<!-- like this -->

// or this

in your CSS file, that you remove them, or replace them with the multi-line C style comment:

Code:
/* Like this */

Otherwise you will also have problems.

Hope this helps,
Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
i am relearning html for my job I haven't used it in years so none of this is published to a website so here' the code itself. The actual HTML Document has this coding

<HTML>
<HEAD>
<TITLE>external style sheet link</TITLE>
<LINK REL="stylesheet" TYPE="text/css" HREF="external.css">
</HEAD>
<BODY>
<HR>ALL THE TYPE I WANT GOES HERE

</BODY>
</HTML>


and the .css file has this coding

<HTML>
<HEAD>
<TITLE>External Style Sheet</TITLE>
<STYLE TYPE="text/css">

BODY {color: white; background: black; font-family: arial;}
H1, H2, H3 {color: red; background: green; font-family: vivaldi; font-size: 36px}
HR {text-align: center; width: 50%; margin-left: 25%; margin-right:25%}
</STYLE>

</HEAD>
</HTML>
 
The CSS file should have [!]ONLY[/!] this in:

Code:
BODY {color: white; background: black; font-family: arial;}
H1, H2, H3 {color: red; background: green; font-family: vivaldi; font-size: 36px}
HR {text-align: center; width: 50%; margin-left: 25%; margin-right:25%}

But I would suggest:

Code:
body {
	color: white;
	background[!]-color[/!]: black;
	font-family: Arial[!], sans-serif[/!];
}
h1, h2, h3 {
	color: red;
	background[!]-color[/!]:
	green; font-family: vivaldi[!], cursive[/!];
	font-size: 36px[!];[/!]
}
hr {
	text-align: center;
	width: 50%;
	margin-left: 25%;
	margin-right:25%[!];[/!]
}

Dan

Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Firstly, change your css file so it only reads like this:

Code:
BODY {color: white; background: black; font-family: arial;}
H1, H2, H3 {color: red; background: green; font-family: vivaldi; font-size: 36px}
HR {text-align: center; width: 50%; margin-left: 25%; margin-right:25%}

The extraneous html in there will cause problems as was mentioned earlier by Dan and Chris.

You will probably be best off finishing the font-size:36px with a ; as well as the margin-right in the HR tag.

I think that's all, but I am sure the others will point anything out I may have missed.

Richard
 
see i've been reteaching myself with books and websites and everyone has <style type=.....> for some reason
 
awesome. it worked. Damn books suck. Thank you all for your help. Never thought I'd be getting back into programming, but I guess you never know what lies ahead.

Thanks again
adam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top