473,322 Members | 1,540 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

@import problem

Hello

I made a site with validated XHTML and CSS. It works fine also.
Only in IE i see the site build up without CSS (very fast though) and
then the CSS is used to build the page.

When i use this it works fine:

<link href="styles/site.css" rel="stylesheet" type="text/css" />

But with this it does not:

<style type="text/css" media="screen"><!-- @import "styles/site.css";
--></style>

Anyone knows why this happens?

Mark

Dec 5 '05 #1
11 2092
Mark wrote:
Hello

I made a site with validated XHTML and CSS. It works fine also.
Only in IE i see the site build up without CSS (very fast though) and
then the CSS is used to build the page.

When i use this it works fine:

<link href="styles/site.css" rel="stylesheet" type="text/css" />

But with this it does not:

<style type="text/css" media="screen"><!-- @import "styles/site.css";
--></style>


Because the CSS interpreter doesn't know what

<!-- @import "styles/site.css"; -->

means. Try

<style type="text/css" media="screen">
<!--
@import "styles/site.css";
-->
</style>

As with your original, this wraps the @import directive into an HMTL
comment so that HTML interpreters that don't know what the <STYLE> tag
is don't try to read its content as HTML. With this arrangement, the CSS
interpreter won't know what either

<!--

or

-->

means. But since the @import directive is now on its own line, the
interpreter will begin afresh, considering the <!-- to be over and done
with and treating the @import directive as something new.
Alternatively, you could dispense with the HTML comment delimiters on
the theory that no one is using CSS-blind user agents any more.
Dec 5 '05 #2
Harlan Messinger wrote:
I made a site with validated XHTML and CSS.
Try

<style type="text/css" media="screen">
<!--
@import "styles/site.css";
-->
</style>


Not in XHTML!

Either:

<style type="text/css" media="screen">
@import "styles/site.css";
</style>

or

<style type="text/css" media="screen"><!--/*--><![CDATA[/*><!--*/
@import "styles/site.css";
/*]]>*/--><!]]></style>

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Dec 5 '05 #3
David Dorward wrote:
Harlan Messinger wrote:

I made a site with validated XHTML and CSS.

Try

<style type="text/css" media="screen">
<!--
@import "styles/site.css";
-->
</style>

Not in XHTML!


Oops, missed that part. Then, yes, the HTML comment delimiters are
pointless--anything that knows XHTML, knows <STYLE>! Not counting your
formulation below for making XHTML work in HTML-only browsers. How
vulgar, though.

Either:

<style type="text/css" media="screen">
@import "styles/site.css";
</style>

or

<style type="text/css" media="screen"><!--/*--><![CDATA[/*><!--*/
@import "styles/site.css";
/*]]>*/--><!]]></style>

Dec 5 '05 #4
Harlan Messinger wrote:
I made a site with validated XHTML and CSS.

Try

<style type="text/css" media="screen">
<!--
@import "styles/site.css";
-->
</style>


Not in XHTML!

Either:

<style type="text/css" media="screen">
@import "styles/site.css";
</style>

or

<style type="text/css" media="screen"><!--/*--><![CDATA[/*><!--*/
@import "styles/site.css";
/*]]>*/--><!]]></style>


Shouldn't that be
@import url(styles/site.css);
?
--
Chris Hughes
"Reality is that which, when you cease to believe, continues to exist."
http://www.epicure.demon.co.uk
Dec 5 '05 #5
Harlan Messinger wrote:
Oops, missed that part. Then, yes, the HTML comment delimiters are
pointless--anything that knows XHTML, knows <STYLE>! Not counting your
formulation below for making XHTML work in HTML-only browsers. How
vulgar, though.


Blame Ian Hixie for it :) (Well, applaud him, and blame the HTML Working
Group for the insane handwaving that is Appendix C ("Oh oh. If we assume
that no HTML user agent actually understands what <br /> means in HTML then
people can serve their XHTML with a text/html Content-Type and not notice
anything wrong when they comment out their styles and scripts!"))
--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Dec 5 '05 #6
The Major wrote:
@import "styles/site.css";
Shouldn't that be
@import url(styles/site.css);
?


Both syntaxes are fine.
http://www.w3.org/TR/CSS2/cascade.html#at-import

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Dec 5 '05 #7
David Dorward wrote:
The Major wrote:

@import "styles/site.css";

Shouldn't that be
@import url(styles/site.css);
?

Both syntaxes are fine.
http://www.w3.org/TR/CSS2/cascade.html#at-import


Okay thanks all.

Question:

is it better than:

<link href="styles/site.css" rel="stylesheet" type="text/css" />

and why?

Mark

Dec 5 '05 #8
Mark wrote:
@import url(styles/site.css);
Question:
is it better than:
<link href="styles/site.css" rel="stylesheet" type="text/css" />
and why?


Pro: IE4 will ignore the styles

Con: IE4 will ignore the styles.
You have a style sheet with nothing in it but an instruction to load a
different stylesheet ... which seems silly.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Dec 5 '05 #9
The Major wrote:

Shouldn't that be
@import url(styles/site.css);
?


I agree. Not sure which one at this moment, but one browser at least
does not work when quotes are used.

--
Gus
Dec 6 '05 #10
David Dorward wrote:
Harlan Messinger wrote:

I made a site with validated XHTML and CSS.


Try

<style type="text/css" media="screen">
<!--
@import "styles/site.css";
-->
</style>

Not in XHTML!

Either:

<style type="text/css" media="screen">
@import "styles/site.css";
</style>

or

<style type="text/css" media="screen"><!--/*--><![CDATA[/*><!--*/
@import "styles/site.css";
/*]]>*/--><!]]></style>


XHTML 1.0 Appendix C states:
Script and Style element contents must be wrapped within a CDATA
marked section
to avoid expansion of entities < and & as start of markup and not to
recognize
&lt; and &amp; as < and & respectively.
<script> || <style>
<![CDATA[
... unescaped script or style content ...
]]>
</script> || </style>
An alternative is to use external script and style documents.
For compatibility with existing HTML 4 user agents, it goes on to say to use
external style sheets or external script if either uses < or & or ]]> or --.
It further notes that the historical practice of hiding scripts and
style sheets
within _comments_ for backward comptibility is likely to not work as
expected.

Ian Hickson expands on this by showing how to use _js/css comments_ with:

<script type="text/javascript"><!--//--><![CDATA[//><!--
...
//--><!]]></script>
and
<style type="text/css"><!--/*--><![CDATA[/*><!--*/
...
/*]]>*/--></style>

which are not necessary if following Appendix C conformance and
compatibility
guidelines unless _comments_ are absolutely necessary, which are not IMHO.

--
Gus
Dec 6 '05 #11
Gus Richter wrote:
Shouldn't that be
@import url(styles/site.css);
?
I agree. Not sure which one at this moment, but one browser at least
does not work when quotes are used.


IE/Mac does not support the url() syntax with _single_ quotes are used.
Double quotes are fine.

--
David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
Home is where the ~/.bashrc is
Dec 7 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Remy Cool | last post by:
Hello, I've created an archive import class (with the help of importers.py from the python /demo/imputil dir) which imports packages and modules from a dictionary. So far so good. The problem...
9
by: Frantisek Fuka | last post by:
This thing keeps bugging me. It's probably some basic misunderstanding on my part but I am stumped. Let's say I have two Python files: file.py and file2.py. Their contents is as follows: ...
0
by: John Roth | last post by:
I've found a case where it seems that Python is importing two copies of a module without any reason or indication. It took me a while to verify that this is what is occuring: I had to write a...
4
by: Achim Domma (Procoders) | last post by:
Hi, in my __init__.py of module A.B if have something like: from win32com.client import Dispatch obj=Dispatch('...') VERSION=tuple() del obj Now I should be able to write:
1
by: Chris | last post by:
Background: I am using a MS Access 2000 front end with SQL Server 8.0 back end. I have the requirement to import all text files (regardless of filename) from a given folder on the network into a...
0
by: Eric Huss | last post by:
I'm having a problem with packages within packages. Here's an example: foo/ foo/__init__.py: empty file foo/sub/__init__.py: from foo.sub.B import B foo/sub/A.py: class A: pass foo/sub/B.py
1
by: Learning Python | last post by:
An example in the book I didn't understood well two modules files recursively import/from each other in recur1.py,we have: x=1 import recur2 y=1
1
by: Richard Holliingsworth | last post by:
Hello: Thanks for your quick response. I'm trying to import a new Excel file into an A2K table and it's truncating the data. One of the Excel columns is a text field that can be up to 2000...
2
by: dwelch91 | last post by:
Hi, c.l.p.'ers- I am having a problem with the import of xml.parsers.expat that has gotten me completely stumped. I have two programs, one a PyQt program and one a command line (text) program...
6
by: bvdp | last post by:
I'm going quite nutty here with an import problem. I've got a fairly complicated program (about 12,000 lines in 34 modules). I just made some "improvements" and get the following error: bob$ mma...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.