© Copyright 2003 Opera Software.
Users of handheld devices expect the Web to the same on their devices as it is on desktops.
Authors of Web sites expect specific control over the rendering of pages on handhelds.
Most Web sites are not designed for handheld devices, so a user stylesheet mode must be provided.
This document describes the technique used to select which mode a bandwidth-constrained handheld device should use.
This specification describes three modes of operation.
handheld
media type.handheld
stylesheets, users should be given the opportunity to switch to this mode, in which the document's CSS stylesheets are applied to the document in the context of the screen
media type.There are two features of documents that should be used to decide which mode to use.
When loading a page, the UA must see if any of the embedded inline stylesheets, as well as any links to external stylesheets, mention the handheld
media type. This is done without fetching any additional resources. Specifically, this means that during the page load the UA must look for:
handheld
in the comma separated media pseudo-attribute of <?xml-stylesheet?>
PIs.handheld
in the comma separated media attribute of <link>
elements that have a value of stylesheet
in their space-separated rel attribute.handheld
in the comma separated media attribute of <style>
elements.@import
or @media rule that mentions the handheld
media type in a <style type="text/css">
element with a media of all
(the default).media="handheld"
in an HTTP Link header with stylesheet
in its space-separated rel
attribute.Specifically, in the first three cases, UAs should not take into account the type attributes, UAs should not take into account if the stylesheets are alternates or persistent, and UAs should not download the files to check they mention handheld
.
Note that links to stylesheets that use the data:
URI scheme must be considered external stylesheets and are not parsed during this exploratory stage. Similarly, even if the external stylesheets are available in the cache, they must be ignored during this stage. In particular, if a document has a single external stylesheet with media="all"
containing an @media "handheld" {}
block, thus triggering SSR mode (no handheld
in the main document), then, if the user switches to screen
mode, then goes to another document, then returns to the first document, the UA should not switch into handheld mode, even though it technically knows that there is handheld
style on the page (since the stylesheet will be in the cache).
In addition to checking the given media types to decide whether the page should be in handheld mode, the UA should also check for certain DTDs to decide whether to avoid going into SSR mode, regardless of the handheld mode setting. The following languages should trigger normal, non-SSR mode:
<!DOCTYPE HTML
PUBLIC "-//W3C//DTD Compact HTML 1.0 Draft//EN">
.application/vnd.wap.xhtml+xml
(ignoring any MIME type
attributes such as 'charset'); anything with a MIME type of
application/xhtml+xml if it has the attribute
profile
with the exact value
"http://www.wapforum.org/xhtml"
(as in
application/xhtml+xml;profile="http://www.wapforum.org/xhtml"
,
but other attributes, such as 'charset', shouldn't affect whether it
matches or not — note that MIME types and MIME parameters are
case insensitive, but MIME parameter values are not); or, for content
sent as text/html
, anything with a DOCTYPE exactly
matching either <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD
XHTML Mobile 1.0//EN"
"http://www.wapforum.org/DTD/xhtml-mobile10.dtd">
or
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile
1.1//EN" "http://www.wapforum.org/DTD/xhtml-mobile11.dtd">
.<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN"
"http://www.wapforum.org/DTD/wml13.dtd">
or
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD WML 2.0//EN"
"http://www.wapforum.org/DTD/wml20.dtd">
. MIME types are
not used to detect WML because all WML documents must start with one
of those DOCTYPEs and thus the MIME type check would be
redundant.Comparing DOCTYPEs should be done by parsing the DOCTYPE string as
follows. First, the string <!DOCTYPE
should be
matched, case insensitively. Then, one or more whitespace characters
should be skipped, and the string html
should be matched
case insensitively for CHTML, and case sensitively for WML and XHTML.
Then, one or more whitespace characters should be skipped, and the
string PUBLIC
should be matched case insensitively. Then
again, one or more whitespace characters should be skipped, and the
FPI, delimited by matching quotes (either "
or
'
) should be matched exactly (case sensitively). Then,
for WML and XHTML, but not for CHTML, whitespace characters should be
skipped, and then another string, delimited by matching quotes again,
should be skipped. Finally, for all DOCTYPEs, a character ">" should
be matched.
If any of the above fails to match, then the DOCTYPE is not considered to be an exact match.
After having checked all these possibilities:
handheld
styles and no mobile DTDs, then it should switch to SSR mode, and give the user the option to use screen
as the media type.handheld
style using the steps above, then it should use the handheld
media type, and give the user the option to switch to SSR mode.handheld
style but did find a mobile DTD, then it should use the screen
media type, and give the user the option to switch to SSR mode.When the device is not in SSR mode all stylesheets that apply to the chosen media type, including any that are linked using the all
media and those that are mentioned in the document before the mention of handheld
, must be applied. For example, if an all
stylesheet is linked before a screen, handheld
stylesheet, then the all
stylesheet should still be used while in handheld
mode).
In terms of the CSS specification, this model is compliant, with the liberal interpretation being that the device's media type is selected after loading the stylesheet instead of being constant.