468,107 Members | 1,356 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,107 developers. It's quick & easy.

How to give rules for choosing style sheets?

I want a device to use styles given for media type handheld and not the
styles given for media type screen, if the device supports media types
handheld and screen. Is it possible without writing all styles specified
for screen again for handheld?

--
Homepage http://www.iki.fi/jarno.suni/
Mar 12 '06 #1
12 1768
On Sun, 12 Mar 2006 20:11:49 +0100, Jarno Suni <lo**@signature.invalid>
wrote:
I want a device to use styles given for media type handheld and not the
styles given for media type screen, if the device supports media types
handheld and screen. Is it possible without writing all styles specified
for screen again for handheld?


Why not use three stylesheets then:
1. one generic with the styles you want both devices (screen and handheld)
to use, and refer to them with media 'all';
2. one specifically for screens, referring to them with media 'screen'
(possibly 'projection' too?);
3. the last one specifically for handhelds, referring to them with media
'handheld'.

Will that do?

See also <URL:http://www.w3.org/TR/REC-CSS2/media.html>

--
______PretLetters:
| weblog | http://www.pretletters.net/weblog/weblog.html |
| webontwerp | http://www.pretletters.net/html/webontwerp.html |
|zweefvliegen | http://www.pretletters.net/html/vliegen.html |
Mar 12 '06 #2
Barbara de Zoete wrote:
Will that do?
Not well, because some handheld devices support both 'handheld' and
'screen', but I want to give totally different style for bigger 'screen'
devices, such as desktop PCs.
See also <URL:http://www.w3.org/TR/REC-CSS2/media.html>


Thanks, but I do not see how I could tell a device to use a sheet, if it
supports 'screen', but does not support 'handheld'.

--
Homepage http://www.iki.fi/jarno.suni/
Mar 12 '06 #3
Barbara de Zoete wrote:
Will that do?
Not well, because some handheld devices support both 'handheld' and
'screen', but I want to give totally different style for bigger 'screen'
devices, such as desktop PCs.
See also <URL:http://www.w3.org/TR/REC-CSS2/media.html>


Thanks, but I do not see how I could tell a device not to use 'screen'
styles, if it also supports 'handheld' styles.

--
Homepage http://www.iki.fi/jarno.suni/
Mar 12 '06 #4
On Sun, 12 Mar 2006 21:38:12 +0100, Jarno Suni <lo**@signature.invalid>
wrote:
Barbara de Zoete wrote:
Will that do?


Not well, because some handheld devices support both 'handheld' and
'screen', but I want to give totally different style for bigger 'screen'
devices, such as desktop PCs.


Put the <link> to the handheld.css last in the head of your page.

--
______PretLetters:
| weblog | http://www.pretletters.net/weblog/weblog.html |
| webontwerp | http://www.pretletters.net/html/webontwerp.html |
|zweefvliegen | http://www.pretletters.net/html/vliegen.html |
Mar 12 '06 #5
Barbara de Zoete wrote:
Put the <link> to the handheld.css last in the head of your page.


Yes, I have done that. But, I have to remember to overwrite screen.css'
specifications in handheld.css. This makes it a little bit tricky to
maintain.

--
Homepage http://www.iki.fi/jarno.suni/
Mar 12 '06 #6
...and the handheld device downloads the screen.css for nothing.

--
Homepage http://www.iki.fi/jarno.suni/
Mar 12 '06 #7
Jarno Suni wrote:
Barbara de Zoete wrote:
Put the <link> to the handheld.css last in the head of your page.


Yes, I have done that. But, I have to remember to overwrite screen.css'
specifications in handheld.css. This makes it a little bit tricky to
maintain.


Welcome to the world of catch 22s. The handheld manufacturer probably set
up their device to accept media type screen due to a general lack of
websites supporting the handheld media type. Now we are faced with
additional work to handle the situation.

To the best of my knowledge, you are stuck with having to rewrite the entire
style sheet for the second media type.

Carolyn
--
Carolyn Marenger

Mar 13 '06 #8
Carolyn Marenger wrote:
To the best of my knowledge, you are stuck with having to rewrite the entire
style sheet for the second media type.


Couldn't W3C add a way to exclude a style to the recommendation, if
device supports some media type:
e.g.
<LINK rel="stylesheet" type="text/css"
media="screen, -handheld" href="real_screen.css">
would give order to use real_screen.css, if device supports 'screen' AND
does NOT support 'handheld'. This wouldn't help the users of old
browsers. BTW Can you update the browser of old mobile phone?

--
Homepage http://www.iki.fi/jarno.suni/
Mar 13 '06 #9
Jarno Suni wrote:
..and the handheld device downloads the screen.css for nothing.

... which would cost some extra money & time to someone who is browsing.

--
Homepage http://www.iki.fi/jarno.suni/
Mar 13 '06 #10
Jarno Suni wrote:
Carolyn Marenger wrote:
To the best of my knowledge, you are stuck with having to rewrite the
entire style sheet for the second media type.


Couldn't W3C add a way to exclude a style to the recommendation, if
device supports some media type:
e.g.
<LINK rel="stylesheet" type="text/css"
media="screen, -handheld" href="real_screen.css">
would give order to use real_screen.css, if device supports 'screen' AND
does NOT support 'handheld'. This wouldn't help the users of old
browsers. BTW Can you update the browser of old mobile phone?


The answer to that is possibly. If you want it, contact w3c and get on
their advisory panel, or at least recommend it to them stating your
justifications. It still becomes an issue for the browser writers to deal
with. Regardless what the standard is, they can always decide to ignore
it. Ultimate decision would probably be based on their sales.

Updating browsers in mobile phones? Contact the manufacturer for that. My
guess is they won't bother, since their focus seems to be make a new model
with new features and sell it to everyone who bought the old and outdated
model. Logical does not always equate with making money.

Carolyn
--
Carolyn Marenger

Mar 13 '06 #11
Jarno Suni wrote:
Jarno Suni wrote:
..and the handheld device downloads the screen.css for nothing.

.. which would cost some extra money & time to someone who is browsing.


Blame the hand-held browser makers for accepting screen media in the
first place. I don't know what they were thinking...

--
Reply email address is a bottomless spam bucket.
Please reply to the group so everyone can share.
Mar 14 '06 #12
Carolyn Marenger wrote:
To the best of my knowledge, you are stuck with having to rewrite the
entire style sheet for the second media type.


I got an idea from the HTML 4.01 Specification, Chapter 14 [1] and tried
to define two preferred style sheets inside <head> section:
<link rel="stylesheet" type="text/css" title="pref" media="handheld"
href="handheld.css" />
<link rel="stylesheet" type="text/css" title="pref" media="screen"
href="screen.css" />

According to the chapter 14.4.1: "Both LINK and STYLE may be used with
the media attribute. The user agent is then responsible for filtering
out those style sheets that do not apply to the current medium." On the
other hand, a standard handheld medium should not use screen.css, if it
supports handheld media type, since in chapter 14.3.2 it is told that
"If two or more LINK elements specify a preferred style sheet, the first
one takes precedence."

Unfortunately, the XHTML browser of the mobile phone I use, does not
follow these rules; it uses both style sheets. I tried to change the
title of the second link tag, but it did not help; in the contrary
Firefox 1.5 uses neither of the style sheets then.

[1] http://www.w3.org/TR/html4/present/styles.html

--
Homepage http://www.iki.fi/jarno.suni/

Mar 14 '06 #13

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Phil Thompson | last post: by
9 posts views Thread by Radium | last post: by
1 post views Thread by mscertified | last post: by
8 posts views Thread by sourpatchkid | last post: by
3 posts views Thread by dennis.sprengers | last post: by
3 posts views Thread by Markus | last post: by
5 posts views Thread by =?Utf-8?B?SmVycnkgQw==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.