How to Use Operating System Styles in CSS

By | | JavaScript & CSS

CSS system stylesOne of the lesser-known features of CSS2.1 is the ability to define fonts and colors that are in use by the underlying Operating System theme. This can be useful in situations when you require tighter OS integration, e.g. HTML help files, Adobe AIR or perhaps offline web applications.

Before we begin, there are a few caveats:

  • Do not rely on these properties working in all OS/browser combinations. If your application must work in Opera on BeOS, then I’d recommend you test it first!
  • The properties have been deprecated in CSS3 in favor of the appearance value type (although browser support is extremely limited at this time).
  • There is nothing to prevent the user defining unusual, clashing, or ugly color schemes in their OS. Pages will reflect their choices — not your designer’s.

System Fonts

System fonts are assigned using the ‘font’ property. Note that the family, size, and style are all assigned as appropriate, e.g.


body
{
	font: caption;
}

The following font values are available. The ‘Example’ column shows the current font set by your OS.

PropertyDescriptionExample
captionControls font (buttons, drop-downs, etc.)ABC abc 123
iconIcon label fontABC abc 123
menuMenu fontABC abc 123
message-boxDialog box fontABC abc 123
small-captionSmall control labelsABC abc 123
status-barStatus bar fontABC abc 123

System Colors

System colors can be assigned to to any property that expects a color value, e.g.


body
{
	color: WindowText;
	background-color: Window;
	border: 2px solid ActiveBorder;
}

The following color values are available. They are shown in CamelCase for legibility, but any casing is valid. The ‘Example’ column shows the color set by your OS.

PropertyDescriptionExample
ActiveBorderActive window border 
ActiveCaptionActive window caption 
AppWorkspaceBackground color of multiple document interface 
BackgroundDesktop background 
ButtonFaceFace color for 3D display elements 
ButtonHighlightDark shadow for 3D display elements (facing away from light) 
ButtonShadowShadow color for 3D display elements 
ButtonTextText on push buttons 
CaptionTextText in caption, size box, and scrollbar arrow box 
GrayTextGrayed (disabled) text (#000 if not supported by OS) 
HighlightItem(s) selected in a control 
HighlightTextText of item(s) selected in a control 
InactiveBorderInactive window border 
InactiveCaptionInactive window caption 
InactiveCaptionTextColor of text in an inactive caption 
InfoBackgroundBackground color for tooltip controls 
InfoTextText color for tooltip controls 
MenuMenu background 
MenuTextText in menus 
ScrollbarScroll bar gray area 
ThreeDDarkShadowDark shadow for 3D display elements 
ThreeDFaceFace color for 3D display elements 
ThreeDHighlightHighlight color for 3D display elements 
ThreeDLightShadowLight color for 3D display elements (facing the light) 
ThreeDShadowDark shadow for 3D display elements 
WindowWindow background 
WindowFrameWindow frame 
WindowTextText in windows 

Would these properties be useful in your next project?

Written By:

Craig Buckler

Craig is a Director of OptimalWorks, a UK consultancy dedicated to building award-winning websites implementing standards, accessibility, SEO, and best-practice techniques.

Website
>> More Posts By Craig Buckler

 

{ 14 comments }

NetNerd85 August 23, 2009 at 4:28 am

Maybe useful for Adobe AIR applications…?

Aroeira August 13, 2009 at 2:42 am

Thanks, Craig. Very useful information

TheTypehouse August 12, 2009 at 7:05 pm

Thanks, Craig. This looks interesting, and I can see that it could be especially so for use with web apps.

BTW, there’s a typo in the sentence “They are shown in CamalCase for legibility” (should read “CamelCase”). :-)

brothercake August 12, 2009 at 2:19 am

An interesting additional note here is that what you mention as a caveat:

There is nothing to prevent the user defining unusual, clashing, or ugly color schemes in their OS

Is also a major reason for using them, if you look it at the other way. It means that for users who need specific color schemes – like high contrast black and yellow – their color schemes will be reflected in the interface, if it uses these system properties.

Connor August 11, 2009 at 10:49 pm

This is exactly what I was looking for. These properties are perfect for web-app GUIs, as anything that blends the app interface with the client OS is a good thing for the user experience.

Any idea how these are handled on mobile browsers?

Craig Buckler August 11, 2009 at 7:55 pm

All the mainstream modern browsers support the properties. Many older browsers do too, including IE6. However, I would suggest you check your target OS/browser combinations to be absolutely certain.

Anonymous August 11, 2009 at 6:57 pm

What’s the browser support for these properties?

ramnath August 11, 2009 at 4:04 pm

Thanks Craig for sharing this.

Yes, I see on possible use for this:

May be an online ‘help’ for a desktop application simulating its interface, as seen on user’s OS.

Counter Argument:
It can be done in much better and interactive ways like Adobe Captivate! :)

brothercake August 11, 2009 at 9:49 am

I even use custom checkboxes!

Well frankly, you shouldn’t. The more uniform you can make your interface, the better its usability. It’s one of the major problems with web applications in general, that each one has a unique-looking interface. It’s all very well to make things look pretty, but to a signficant extent, you do so at the expense of your users.

brothercake August 11, 2009 at 9:46 am

Hell yeah, I use this stuff all the time.

#1 most useful application is custom tooltips:

#tooltip
{
position:absolute;
display:block;
background:InfoBackground;
color:InfoText;
font:small-caption;
padding:2px 2px 2px 4px;
border:1px solid;
border-color:ButtonShadow ButtonHighlight ButtonHighlight ButtonShadow;
max-width:200px;
}

neal kernohan August 11, 2009 at 8:26 am

Browsers not only support websites, they also support thousands of web applications used in corporate environments. Many of these clients want these applications to look, feel and perform like desktop apps. This helps many designers do exactly that.

scotthoff August 11, 2009 at 6:37 am

Well it is interesting.

1 August 11, 2009 at 5:39 am

Very interesting article but I really don’t see how this can fit in some nice looking web page. I even use custom checkboxes! I want to use custom scrollbars even… that time is not now, but it will come.
Web pages should look well designed and developed good, if any user specified something for his OS it does’t mean it will fit in any place inside the web page.

Dean C August 11, 2009 at 4:08 am

I don’t think so. A browser window to me is a shell, it’s my job to make things look nice within that shell. Blending in to the surrounding shell is not something I want to do.

Comments on this entry are closed.