471,873 Members | 1,923 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,873 software developers and data experts.

HTML will not link to CSS file

I just started to learn. I can't get the code in my CSS file to link to my HTML file to produce the web page I want.

The code I've used is;

<link rel="stylesheet" type="txt/css" href="bkkcss.css /">


And in the CSS sheet is;

body
{margin:0;
padding:0;
background-color:##003300
}


And when I validate I get the following which I don't fully understand;

The validator has found the following problem(s) prior to validation, which should be addressed in priority:

Missing "charset" attribute for "text/xml" document.
The HTTP Content-Type header (text/xml) sent by your web browser (Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)) did not contain a "charset" parameter, but the Content-Type was one of the XML text/* sub-types.

The relevant specification (RFC 3023) specifies a strong default of "us-ascii" for such documents so we will use this value regardless of any encoding you may have indicated elsewhere.

If you would like to use a different encoding, you should arrange to have your browser send this new encoding information.

Conflict between Mime Type and Document Type
The document is being served with the text/xml Mime Type which is not a registered media type for the XHTML 1.1 Document Type. The recommended media type for this document is: application/xhtml+xml

Using a wrong media type for a certain document type may confuse the validator and other user agents with respect to the nature of the document, and you may get some erroneous validation errors. How to fix this problem? One of the following techniques should help:

If you are serving a static file on a Web server, changing its extension should help. Use e.g .xhtml for XHTML or .mathml for MathML.
You may need to reconfigure your Web server. This Setting up MIME Types tutorial has instructions for Apache, Tomcat and IIS.
If the document is generated dynamically, the scripting language should allow you to set up the mime type: this article on MIME Types and Content Negotiation has examples in PHP, Perl, and ASP.


I am in an internet place in Bangkok so maybe the browser isn't very good. I've tried Firefox and IE.

When I put the CSS code and HTML code in the same file I'm getting things to work ok.

Regards

Jim Walsh
Aug 14 '07 #1
5 2369
MrPutty
13
Hey Jim,

have you checked your paths? Throw both files in the same directory.

<link rel="stylesheet" type="txt/css" href="bkkcss.css /">
and try without "/"
<link rel="stylesheet" type="txt/css" href="bkkcss.css">

That should work for you.
Aug 14 '07 #2
drhowarddrfine
7,435 Expert 4TB
1) For the background-color, there should be only one '#' symbol.
2) There is no mime-type of text/xml and should be changed to 'application/xml' but are you truly using XML?
3) application/xhtml+xml is only recognized by modern browsers and not Internet Explorer.
Aug 14 '07 #3
Hey Jim,

have you checked your paths? Throw both files in the same directory.

<link rel="stylesheet" type="txt/css" href="bkkcss.css /">
and try without "/"
<link rel="stylesheet" type="txt/css" href="bkkcss.css">

That should work for you.
Thanks for your time Mr Putty. Truly appreciated.

I took the / off and it worked just fine.

Regards

Jim Walsh
Aug 15 '07 #4
1) For the background-color, there should be only one '#' symbol.
2) There is no mime-type of text/xml and should be changed to 'application/xml' but are you truly using XML?
3) application/xhtml+xml is only recognized by modern browsers and not Internet Explorer.
Hi drhowarddrfine

The extra # was careless. I actually sorted the problem by taking the final / from the link field.

So where do I change text/xml to application/xml? Maybe it's obvious to you but I've only been doing this for a week and not everything is easy yet. And as for really using xml, I've no idea. I got a book called HTML and CSS in 24 Hours by Dick Oliver and Mchael Morrison and took it from there.

It's real good fun though.

And sincere thanks for your time.

Regards

Jim Walsh
Aug 15 '07 #5
MrPutty
13
Hello Jim,

I'd like to recommend using a directory structure when coding. It'll make life a lot easier on you when projects start to grow. What you'll need for now is:

- a root directory (helps when you upload your project to a sever)
- a directory for: html docs, css docs and images.

possible structure:
- html
+ - doc
+ - css
+ - img

Just my two cents on this matter. The HTML code below uses the structure above to link to the stylesheet. href="../css/stylesheet.css"

you can try this: use the HTML below and fill in your <body> content. Adjust the path to the stylesheet, if needed. Your stylesheet looks fine to me (after drhowarddrfines correction). Try and valdiate your code.

Hope this works for you!

Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
  2. <html>
  3. <head>
  4. <title></title>
  5. <link rel="stylesheet" type="text/css" href="../css/bkkcss.css">
  6. </head>
  7. <body>
  8. REMOVE THIS - YOUR CONTENT GOES HERE
  9. </body>
  10. </html>
Aug 15 '07 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

11 posts views Thread by Brett | last post: by
8 posts views Thread by mark126 | last post: by
78 posts views Thread by Robert Baer | last post: by
14 posts views Thread by Rob Meade | last post: by
1 post views Thread by Nogusta123 | last post: by
7 posts views Thread by Xah Lee | last post: by
17 posts views Thread by =?Utf-8?B?Y2F0aGFyaW51cyB2YW4gZGVyIHdlcmY=?= | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.