Adobe
Products
Acrobat
Creative Cloud
Creative Suite
Digital Marketing Suite
Digital Publishing Suite
Elements
Photoshop
Touch Apps
Student and Teacher Editions
More products
Solutions
Digital marketing
Digital media
Education
Financial services
Government
Web Experience Management
More solutions
Learning Help Downloads Company
Buy
Home use for personal and home office
Education for students, educators, and staff
Business for small and medium businesses
Licensing programs for businesses, schools, and government
Special offers
Search
 
Info Sign in
Welcome,
My cart
My orders My Adobe
My Adobe
My orders
My information
My preferences
My products and services
Sign out
Why sign in? Sign in to manage your account and access trial downloads, product extensions, community areas, and more.
Adobe
Products Sections Buy   Search  
Solutions Company
Help Learning
Sign in Sign out My orders My Adobe
Preorder Estimated Availability Date. Your credit card will not be charged until the product is shipped. Estimated availability date is subject to change. Preorder Estimated Availability Date. Your credit card will not be charged until the product is ready to download. Estimated availability date is subject to change.
Qty:
Purchase requires verification of academic eligibility
Subtotal
Review and Checkout
Adobe Developer Connection / HTML5, CSS3, and JavaScript /

CSS3 basics

by Andrew Trice

Andrew Trice
  • Adobe Systems, Inc.

Content

  • What's new?
  • CSS3 != HTML5
  • CSS3 adoption
  • Where to go from here

Modified

10 May 2011

Page tools

Share on Facebook
Share on Twitter
Share on LinkedIn
Bookmark
Print
CSS3 Dreamweaver HTML5 mobile

If you have ever been in the world of web development, chances are that you have heard of CSS, or more formally, cascading style sheets. If you aren't familiar with CSS, it is a language that is used to define how HTML-based content is displayed on the web. CSS can be used to control layout, spacing, colors, fonts, and much more, and has been an integral component of "the Web" since it began gaining popularity in the mid-1990s.

If you are actively engaged in designing or developing web content, then chances are that you have also heard of CSS3. Though you may have heard of it, you might be wondering what it is, and how it differs from existing implementations of CSS.

All technologies mature over time, hence the common adoption of version numbers and terms such as "beta." These labels allow you to identify which version of a particular technology you are using, and thus you can reliably expect what kind of features that piece of software will support. CSS3 is the third iteration of the CSS standard; it is a maturation of the cascading style sheets language that defines new features that allow for richer presentation of content within HTML.

What's new?

Since its inception, CSS has allowed you to tailor the presentation of information within your HTML content. Fonts, colors, background images, solid borders, and so on are all easily configured via existing CSS styles. CSS3 does not detract from the existing capabilities from the Web; rather, it augments and extends the capabilities of the browser to support richer features and richer presentation of HTML-based content.

CSS3 modules

Previous iterations of the CSS specifications were all-encompassing definitions of what makes up the CSS language. In CSS3, the specification has been broken up into a collection of smaller specifications, referred to as modules. Each module defines aspects within a given subset of functionality. One module covers media selectors, another covers colors, another covers SVG, and so on. The modular approach allows for specific aspects of the CSS specification to be approved and implemented as a standard sooner than having one massive specification that includes all features; which would undoubtedly take much longer to become ratified as a standard. In a nutshell, this means that it is an evolving standard, where specific aspects may become standardized before others. You can learn more about the modular design of the CSS3 specification through the W3C.

CSS3 features

Since its inception, CSS has allowed you to tailor the presentation of information within your HTML content. Fonts, colors, background images, solid borders, and so on are all easily configured via existing CSS styles. CSS3 does not detract from the existing capabilities from the Web; rather, it augments and extends the capabilities of the browser to support richer features and richer presentation of HTML-based content.

The Web 2.0 movement brought with it a new level of design in web-based interfaces. No longer were web pages an organization of solid colors, images, and squares. HTML-based interfaces began to emerge which employed nonstandard fonts, complex color gradients, rounded corners, and overall, a much more polished and refined look and feel. The combined HTML and CSS that were used to create these interfaces often became complex, fragile, and unwieldy. CSS3 introduces new styles for much easier control over the presentation of these sophisticated interfaces.

CSS3 defines styles that control the corner radius of divs, spans, or other HTML elements; thus creating a rounded box no longer requires multiple nested HTML containers and chopped up image assets. It can now be specified through simple CSS definitions, on a single HTML container.

Figure 1. Rounded corners
Figure 1. Rounded corners

In addition to rounding the corners of HTML containers, CSS3 defines new styles for the borders of HTML container elements. Through simple CSS style definitions, developers and designers will now be able to easily create complex borders that are not limited to simple dotted or dashed lines, rather they can be based on tiled or stretched image assets Again, this is a feature that enables quick-and-easy development of complex visual interfaces, yet with minimal complexity in the underlying code.

Following inline with visual changes using simple code: CSS3 introduces capabilities for adding drop shadows to both HTML containers and text segments, adds the ability to define multi-column text layouts, and even support for web fonts (the usage of custom, non-standard fonts within HTML interfaces).

Figure 2. Drop shadows
Figure 2. Drop shadows

CSS3 also introduces powerful new methods for controlling color and opacity of content within HTML. CSS3 introduces support for HSL (Hue, Saturation, and Lightness), HSLA (HSL with Alpha), RGB (Red, Green, Blue), and RGBA (RGB with Alpha) color spaces. These allow for more refined control of presentation, and better control of content alpha within your HTML documents. In addition to the support of additional color spaces, CSS3 also enables support of complex color gradients using any of these color spaces, including alpha gradients.

Figure 3. Opacity and Gradients
Figure 3. Opacity and Gradients

One notable addition with CSS3 is the support of media queries. CSS3 media queries allow designers and developers to create style sheets that apply to specific screen dimensions. Using media queries, a singular HTML document can have a varied presentation on a range of screens or devices. A designer or developer can create styles that are selectively applied based upon the dimensions of the screen where content is being viewed. Therefore, differing layout and presentation for tablet-based interfaces, mobile phone interfaces, and desktop interfaces can be applied to the same HTML document.

Figure 4. Media queries
Figure 4. Media queries

Media queries aren't the only way that you can have conditional styles applied to your HTML content via CSS. Selectors are not new in CSS3, however CSS3 defines many additional selectors for your use. Selectors are conditional rules for applying style sheets to HTML elements. Any time you have used a :hover style on a link style, you have used a selector. The new CSS3 selectors can be used to apply styles to specific elements, first-child elements, last-child elements, sibling elements, and many other scenarios. You can read about all of the difference selector rules in the W3C specification.

Another notable addition with CSS3 is the inclusion of transformations. Transformations are styles that control the transformation of the visual display of a particular object. 2D transformations apply to a dimensional space, such as translation on the x or y axes, scaling horizontally and vertically, rotating around the point of origin, or even skewing content in both the x and y directions. All browsers that support CSS3 support 2D transformations, however, some browsers even support CSS3 3D transformations. 3D transformations are more-or-less the same as those available with 2D transformations, with the addition of the third axis. 3D transformations enable scaling, translation, and rotating in a three dimensional space, along the x (horizontal), y (vertical), or z (depth) axes. For more information on 2D transformations and 3D transformations refer to the W3C site.

Another extremely powerful addition is that CSS3 introduces animations and transitions through CSS styles. Animations and transitions are a fairly significant step for CSS. These features allow you to create style sheets that define animation of specific content, or transitions from one visual state to another. Web designers and developers no longer have to rely solely upon JavaScript and timer events for animating content within the browser. With CSS3 animations and transitions, style sheets can be defined that abstract the animation logic away from the actual HTML structure, and no scripting is involved in any way. As an added bonus, some browsers even support hardware acceleration for optimized playback and animation quality. The W3C site provides more information on CSS animations and transitions.

Figure 5. Transitions
Figure 5. Transitions

Although this is not an exhaustive list of all of the new features included within CSS3, hopefully it will give you an idea of what CSS3 makes possible, and how use of CSS3 can help you simplify your HTML content.

CSS3 != HTML5

CSS3 has commonly been misconceived as a subset of HTML5 features. While CSS3 and HTML5 often accompany each other, they are not synonymous. HTML5 is the fifth iteration of the HTML (Hyper Text Markup Language) specification, which is used to define the structure, content, and capabilities within HTML documents. HTML5 allows for new tags and support of richer media, whereas CSS3 defines new rules for customizing the presentation of the user interface. CSS3 defines how that HTML content will actually be presented within the browser.

CSS3 adoption

Now that we have a general idea of what CSS3 is, it is important to know where you can actually use it. All of the major desktop browsers (Internet Explorer, Chrome, Firefox, Safari, Opera) support many CSS3 features. However, only the latest versions of these browsers actually support the majority of these CSS3 features. Older versions of these popular browsers may not support all, if any CSS3 features. If you do take advantage of CSS3 styles of features within your own content, you may want to be sure that your target audience can support those features before proceeding too far. A great resource for verifying the compatibility of CSS3 features in different browsers is www.caniuse.com, which lists browser support for individual CSS3 features.

If you are targeting mobile browsers, then you're in luck. CSS3 is supported by most of the latest smartphone operating systems. This includes the default web browsers for iOS, Android, BlackBerry, and even the latest generation of Windows devices. In fact, mobile browsers have some of the best support for CSS3 features. The catch is that not all desktop and mobile browsers support all of the features equally.

In addition to the fact that not all browsers support all CSS3 features to the same level, some features may work better in a particular browser than they do in others, even though both may "support" a given feature. This is especially true when comparing the result in a hardware-accelerated browser to that of a nonhardware-accelerated browser.

If that wasn't enough, CSS3 can get even more confusing by the fact that not all browsers support the same syntax for particular CSS3 features. Since the CSS3 specification is not yet standardized, many browser vendors prefix their CSS3 styles with browser-specific identifiers. As an example, using the CSS3 style " -webkit-border-radius " will only work in browsers based upon the webkit engine, even though other browsers support their own CSS3 border-radius implementation. Until the CSS3 specification is finally implemented as a standard, these kinds of inconsistencies will be evident, and will need to be worked around.

Where to go from here

CSS3 features offer powerful additions to the CSS language. Through the use of CSS3, web designers and developers can more easily create complex and sophisticated layouts, dynamic layouts that morph to fit the consuming screen, as well as sophisticated animation and transition sequences, which are often thought only possible with plugin-based content.

The following resources should help you get started with CSS3:

  • Start using CSS3 today
  • CSS3.info
  • Wikipedia: Cascading Style Sheets
  • W3C: Cascading Style Sheets
  • W3C: Introduction to CSS3
  • caniuse.com

Lastly, be sure to check out Chrome Experiments, a showcase for web projects built with CSS3 and other web technologies.

Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License+Adobe Commercial Rights

This work is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 Unported License. Permissions beyond the scope of this license, pertaining to the examples of code included within this work are available at Adobe.

More Like This

  • Using the Geolocation API
  • Developing HTML5 games with Impact JavaScript game engine and Dreamweaver CS5.5
  • Introducing the HTML5 storage APIs
  • Introducing theexpressiveweb.com beta
  • Adobe, standards, and HTML5
  • Real-time data exchange in HTML5 with WebSockets
  • Pseudo-classical object-oriented programming in JavaScript with Minion
  • Object types in JavaScript
  • Backbone.js Wine Cellar tutorial – Part 2: CRUD
  • JavaScript object creation: Learning to live without "new"

Products

  • Acrobat
  • Creative Cloud
  • Creative Suite
  • Digital Marketing Suite
  • Digital Publishing Suite
  • Elements
  • Mobile Apps
  • Photoshop
  • Touch Apps
  • Student and Teacher Editions

Solutions

  • Digital marketing
  • Digital media
  • Web Experience Management

Industries

  • Education
  • Financial services
  • Government

Help

  • Product help centers
  • Orders and returns
  • Downloading and installing
  • My Adobe

Learning

  • Adobe Developer Connection
  • Adobe TV
  • Training and certification
  • Forums
  • Design Center

Ways to buy

  • For personal and home office
  • For students, educators, and staff
  • For small and medium businesses
  • For businesses, schools, and government
  • Special offers

Downloads

  • Adobe Reader
  • Adobe Flash Player
  • Adobe AIR
  • Adobe Shockwave Player

Company

  • News room
  • Partner programs
  • Corporate social responsibility
  • Career opportunities
  • Investor Relations
  • Events
  • Legal
  • Security
  • Contact Adobe
Choose your region United States (Change)
Choose your region Close

North America

Europe, Middle East and Africa

Asia Pacific

  • Canada - English
  • Canada - Français
  • Latinoamérica
  • México
  • United States

South America

  • Brasil
  • Africa - English
  • Österreich - Deutsch
  • Belgium - English
  • Belgique - Français
  • België - Nederlands
  • България
  • Hrvatska
  • Česká republika
  • Danmark
  • Eastern Europe - English
  • Eesti
  • Suomi
  • France
  • Deutschland
  • Magyarország
  • Ireland
  • Israel - English
  • ישראל - עברית
  • Italia
  • Latvija
  • Lietuva
  • Luxembourg - Deutsch
  • Luxembourg - English
  • Luxembourg - Français
  • الشرق الأوسط وشمال أفريقيا - اللغة العربية
  • Middle East and North Africa - English
  • Moyen-Orient et Afrique du Nord - Français
  • Nederland
  • Norge
  • Polska
  • Portugal
  • România
  • Россия
  • Srbija
  • Slovensko
  • Slovenija
  • España
  • Sverige
  • Schweiz - Deutsch
  • Suisse - Français
  • Svizzera - Italiano
  • Türkiye
  • Україна
  • United Kingdom
  • Australia
  • 中国
  • 中國香港特別行政區
  • Hong Kong S.A.R. of China
  • India - English
  • 日本
  • 한국
  • New Zealand
  • 台灣

Southeast Asia

  • Includes Indonesia, Malaysia, Philippines, Singapore, Thailand, and Vietnam - English

Copyright © 2012 Adobe Systems Incorporated. All rights reserved.

Terms of Use | Privacy Policy and Cookies (Updated)

Ad Choices

Reviewed by TRUSTe: site privacy statement