Advertisement
General

CSS4 is Coming: What You Need to Know

by

The Internet is constantly evolving — it's hard to believe rickrolling is six years old, Internet Explorer 6 is twelve years old, and CSS is nearing the public release of version 4.

So what's new in CSS4? I've taken a look through the entire CSS4 spec, hand-picking the best parts. Here are just a few of them.

april-1-warning

Presponsive Layout

Responsive design is undoubtedly the big thing of 2013. With @media queries, it's never been easier to adapt your site for multiple devices and screen sizes, giving your user a better experience. The only real obstacle left in the responsive way is page loads: connection speeds are still worryingly slow for a large proportion of visitors, and the W3C are aware of that. That's why there's a proposal for presponsive design, which would let you apply preload states for slower connections.

april-1-flux-capacitor-rwd

Of course, this technology doesn't come cheap. You'll need a fancy new flux processor chip, which only comes with the latest fibre-optic connections.

@media (flux-capacitor: true) {
    88mph {
        body { background: url('loading.gif'); }
    }
}

Cascading Scriptsheets

This feature was actually introduced by Internet Explorer under the term behavior. If you've ever used a PNG fix, you've used this before. It's incredibly useful for enhancing interaction like never before, and it's helping to bridge the gap and feud between JavaScript and CSS developers. It uses unobtrusive, function-style syntax, and looks like this:

*:hover {
    script: script(alert('hello world'));
}

Here's the equivalent in JavaScript:

var doc = document;
var star = doc.all;

window.hello_world = function(message) {
    message = message || 'hello world';
    alert(message);
}

for(var i = 0; i < star.length; i++) {
    if(star[i] && star[i].nodeName) {
        star[i].onmouseover = function() {
            if(window.hello_world) {
                hello_world();
            }
        }
    }
}

Server-side Stylesheets (CLISS)

If you've ever had to work in a command-line interface before, you'll notice that it's a bit - well, boring - to look at. The CSS4 spec attempts to amend this by introducing the CLISS module.

april-1-cliss

CLISS stands for Command-Line Interface Styling Scriptsheets, and it follows a very similar syntax to the CSS you're used to working on with websites, but can now be used to make your Terminal a little bit brighter. Currently, there's support for the Unix, OS X and Windows command-line applications, provided an optional module is installed. Unlike existing styling options within the application, CLISS allows the entire CSS property set, allowing full customization. Right now, the selector stack is very limited (terminal, line, and error), but there's a lot more in the works.

The syntax looks like this:

terminal {
    background: url("puppies.gif");
    color: #f0f;
    transform: rotate(-90deg);
}
    terminal error {
        display: none; /* Never write bad code again */
    }

Proper Email Styling Support

CSS is overrated anyway - W3C

Yes, you did just read that right. The W3C are working with a range of email providers to give you a consistent, modern approach to styling and authoring HTML emails.

This could mean we can finally start using semantic <article>, <section>, and even <div> tags, stop using inline stylesheets, and finally move to a centralised, external stylesheet system — really get things up to date with the rest of the web.

However, they all agreed that "tables were alright", quoting that "CSS is overrated anyway", so nothing's changed. Ah well.


New and Old Properties

With the advent of CSS4, some old properties have been reintroduced and some have been given to the world for the very first time.

Among the resurrected properties are text-decoration: blink, text-decoration: marquee, font-style: wordart, and font-family: "Comic Sans MS", which are designed to bring typography up to the standards set by the Gutenburg press of the thirteenth century.

The newer properties include retina: true (which automatically enhances your images, CSI:Miami-style), background-music: muzak (which gives your eCommerce sites a true shopfront feeling), and -webkit-typos: false (which utilises iOS’ hyper-accurate spellchecking software to automatically fix typos in YouTube comments).



To Conclude

It's a great time to be working on the web right now, and it's getting better and better; evolving from strength to strength, enabling people from around the world to connect and make great things like this.

Keep creating, and show us what great CSS4 demos you've made in the comments!

Related Posts
  • Code
    JavaScript & AJAX
    Creating Brackets ExtensionsDeeper in brackets retina preview
    A little while ago I wrote about the recent updates to the Brackets editor. Brackets is an open source project focused on web standards and built with web technologies. It has a narrow focus and therefore may not have a particular feature you've come to depend upon. Luckily, Brackets ships with a powerful extension API that lets you add any number of new features. In this article, I'm going to discuss this API and demonstrate how you can build your own extensions.Read More…
  • Web Design
    UX
    Walk Users Through Your Website With Bootstrap TourTour retina
    When you have a web application which requires some getting used to from your users, a walkthrough of the interface is in order. Creating a walkthrough directly on top of the interface makes things very clear, so that's what we're going to build, using Bootstrap Tour.Read More…
  • Code
    JavaScript & AJAX
    Ember Components: A Deep DiveEmber components retina preview
    Ember.js is a JavaScript MVC framework that allows developers to create ambitious web applications. Although pure MVC allows a developer to separate concerns, it does not provide you with all the tools and your application will need other constructs. Today, I'm going to talk about one of those constructs. Ember components are essentially sandboxed re-usable chunks of UI. If you are not familiar with Ember, please check out Getting Started With Ember.js or the Let's Learn Ember Course. In this tutorial, we will cover the Web Components specification, learn how to write a component in Ember, talk about composition, explain the difference between an Ember view and an Ember component, and practice integrating plugins with Ember components.Read More…
  • Code
    JavaScript & AJAX
    Testing in Node.jsNodejs testing chai retina preview
    A test driven development cycle simplifies the thought process of writing code, makes it easier, and quicker in the long run. But just writing tests is not enough by itself, knowing the kinds of tests to write and how to structure code to conform to this pattern is what it's all about. In this article we will take a look at building a small app in Node.js following a TDD pattern.Read More…
  • Code
    JavaScript & AJAX
    Handlebars.js - a Behind the Scenes LookHandlebars behind scenes retina preview
    Handlebars has been gaining popularity with its adoption in frameworks like Meteor and Ember.js, but what is really going on behind the scenes of this exciting templating engine? In this article we will take a deep look through the underlying process Handlebars goes through to compile your templates.Read More…
  • Code
    Articles
    What Are You Using?Preview 400
    We spend a lot of time following the thought leaders in web development, in many cases using the tools and libraries they've built, reading the posts they've written, articulating cool techniques they've learned, and in some cases, attending the defining conference for a specific language. But wouldn't it be great to learn what they focus on and what they use to build such awesomeness?Read More…