Forum Moderators: not2easy

Message Too Old, No Replies

Import Problem

Import Problem I think

         

outrun

4:38 am on Jul 3, 2003 (gmt 0)

10+ Year Member



Ok I have Just took the dive into xhtml strict and Im loving it everything validates except for the following error with CSS validator. Im testing things on local machine. Am I missing something?, I think its my import url but im not sure.

Errors
URI : file://localhost/first.htm
Line: 7

Parse error - Unrecognized : <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>First Xhtml</title> <link rel="stylesheet" href="first/basic.css" type="text/css" /> <style type="text/css" media="screen"> @import url(http://127.0.0.1/layout.css);

thanks in advance.

regards,
Mark

MWpro

4:56 am on Jul 3, 2003 (gmt 0)

10+ Year Member



Can you make it a little clearer as to which line the error is occuring on? (Just post that line)

Is it the <style .. > line?

If so have you included a closing style tag? (</style>) Taking another guess: try putting quotes in the url part like this url("style.css");

outrun

6:10 am on Jul 3, 2003 (gmt 0)

10+ Year Member



Thanks for the reply yes the style does close and I tried putting the url in quotes
This is line 7

@import url("http://127.0.0.1/layout.css");

I tried just

@import url("layout.css");

still the same error as above, underneath import I have

h3 {
margin-bottom: 1em;
}

regards,
Mark

DrDoc

6:57 am on Jul 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



About quotes vs. no quotes:

Correct:
@import url(style.css);
@import "style.css";

Wrong:
@import url("style.css");
@import style.css

Most browsers are forgiving, but it never hurt to do things right ;)

Now, to the problem. Do you have a Web server installed? What happens if you point the browser to [127.0.0.1?...]

Have you tried changing the path for the CSS file to file://localhost/layout.css?

What exactly of the above do you have on line 7?

outrun

7:43 am on Jul 3, 2003 (gmt 0)

10+ Year Member



@import url(http://127.0.0.1/layout.css);
Thats line 7, The CSS works Fine, if I use localhost it doesnt work at all, maybe I should try download the validator instead of uploading to the W3C server to validate, I think because it cant find the layout.css it comes up with errors. I'll let you know what happens.

regards,
Mark

outrun

8:02 am on Jul 3, 2003 (gmt 0)

10+ Year Member



Ok that didnt work but i have realised something its not import this is my style definitions for that page

<style type="text/css" media="screen">
@import "http:/127.0.0.1/layout.css";
.leftmenu ul {
margin: 0px;
padding: 0px 0px 10px 15px;
list-style-type: square;
}
h3 {
margin-bottom: 1em;
}
pre {
margin: 15px;
padding: 10px;
border: 1px dashed #ccc;
color: #006;
background-color: transparent;
}
</style>

Then it says error at Line 7 but everything after that it is fine, displaying the valid css, if I delete the @import line it then says line 12 is invalid which is the next definition

.leftmenu ul {
margin: 0px;
padding: 0px 0px 10px 15px;
list-style-type: square;
}

and It says the rest of the definitions are fine so I delete that then it says the h3 line is an error, this really baffles me, the only time it validates is if I just have

<style type="text/css" media="screen"></style>

which defeats the purpose it wont let me define anything in there without an error, Am I doing something wrong that is so simple I dont see it.

regards,
Mark

killroy

8:26 am on Jul 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you mean that if your remove the @import line it validates fine?

SN

outrun

9:00 am on Jul 3, 2003 (gmt 0)

10+ Year Member



If I remove the @import it says the next definition line is invalid, like I said it will only validate using

<style type="text/css" media="screen"></style>

The followoing wont work

<style type="text/css" media="screen">
.leftmenu ul {
margin: 0px;
padding: 0px 0px 10px 15px;
list-style-type: square;
}
</style>

anything in between doesnt work, I think im gonna stuff the validation cause it works fine on every browser I have tried.

regards,
Mark

MWpro

3:17 pm on Jul 3, 2003 (gmt 0)

10+ Year Member




Correct:
@import url(style.css);
@import "style.css";

Wrong:
@import url("style.css");
@import style.css

I don't think the w3 is wrong in this case...
www.w3.org/TR/REC-CSS2/cascade.html#at-import

If that's how they do it, how can you say it's wrong?

DrDoc

3:44 pm on Jul 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



W3C is not been consistent (depending on who's writing the article):

[w3.org...]
[w3.org...]
[w3.org...]

I can't find the exact page with the explanatory recommendation from W3C, even though I know I've posted something about it before.

drbrain

3:48 pm on Jul 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



@import url("foo.css");
@import url('foo.css');
@import url(foo.css);
@import "foo.css";
@import 'foo.css';

Are all valid. Try it in the validator (you have to actually link to a CSS file for it to work though).

As a side note, arlier this week I found that you can match:

<div class="-">foo</div>
<div class="1">foo</div>
<div class="^J">foo</div>

With selectors, reading the grammar pays off!

DrDoc

3:51 pm on Jul 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Then there's always the issue of browsers choking on the quotes:

[webmasterworld.com...]

And, what defines a quote? Well, technically there is a variety of quotation marks we could use: " ' ` etc. But some of those would, of course, not be suitable in this situation. However, there are still certain issues even if just regular straight quotes (single or double) are used.

DrDoc

4:06 pm on Jul 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, I know it validates... Maybe I should've called it something else, instead of "wrong". W3C itself has encouraged not using quotes within url() statements. They are allowed for backward compatibility (just as @import "foo.css";). However, certain browsers do have issues with quotes, especially in inline styles.

drbrain

4:16 pm on Jul 3, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hrm, I get similar error messages with or without an import, and using XHTML or HTML. It could be that the validator doesn't recognize the html. Using the URI method on an HTML file works, but uploading an HTML file does not.

outrun

11:53 pm on Jul 3, 2003 (gmt 0)

10+ Year Member



I feel like the biggest idiot I should have uploaded it to to my server to validate cause it valditates absolutely fine now, no errors, thanks for the the hint drbrain, I have faith in W3 standards once again.

regards,
Mark

P.S. Thanks everyone who tried to help as well.