Designing and Debugging Web Layouts With CSS Regions

The adoption of CSS Regions is definitely moving along swiftly.  They are now supported in Mobile Safari on iOS7, Opera, Chrome Canary, Chrome Stable & WebKit nightly. Browser support continues to evolve and can be tracked here.

CSS Regions allow you to define content that can “flow” through a series of defined regions on the page, so you can create magazine-type layouts and responsive websites through simple CSS.  I wrote about how you can use CSS Regions for creating responsive content in an earlier article.  I’d definitely recommend reading that before continuing here if you haven’t already done so.  It should give you a good basic understanding of how CSS Regions work.

Defining one piece of HTML markup as the source for another piece of markup is an extremely powerful, but very different way of thinking about Web page layout. You’re very likely going to want good authoring tools, and the ability to debug in-browser to figure what’s going on when your site behaves unexpectedly.

What we’ll describe here are some options for authoring and debugging Web layouts that use CSS Regions.


As far as tools go for authoring content with CSS Regions, your best and only option at this point is Edge Reflow CC, Adobe’s Responsive Web design tool. Within Reflow, you can easily lay out linked region containers exactly where you want them to be placed, define how you want the different region containers to react (resize, move, hide, etc) to different screen resolutions and/or window sizes , and then define a block of content (text, images, videos, etc) to flow into the linked regions.

Vincent Hardy, Director of Engineering for the Adobe Web Platform team, describes here in detail how CSS Regions work, and how they are supported in Edge Reflow.  As well, in the following video, Jacob Surber, product manager for Edge Reflow, shows you how to design your Web layouts in Reflow using CSS Regions:

A Virtuous Circle

What is pretty amazing here, is that CSS Regions is a W3C spec that was first introduced by Adobe.  It has received widespread support across the browser community in a short amount of time.  CSS Regions are now even supported on iOS7 mobile Safari, and thus will likely show up in the next release of desktop Safari in the upcoming release of Mavericks.

Now that it has received enough industry adoption, Adobe is starting to incorporate the feature into its design tools.  Hopefully, designers will start using this feature, and demand more design-focused features like this. The demand will produce new standards and new browser features, and so it goes, round and round. This is a really nice virtuous circle.

Screen Shot 2013-10-10 at 11.27.34 AM

In-Browser Debugging

Once you’ve authored your regions-based content and are viewing it in the browser, you’re still going to want be able to inspect your layouts and pick apart what’s going on, especially when your site is not behaving as expected. There are several in-browser options available to help you visualize and debug your layouts and explore the different content flows, depending on which browser you are using.

WebKit Nightly

CSS Regions are enabled by default on WebKit nightly, so once you’ve downloaded the latest nightly, you’re good to go. Support was added very recently to provide some very nice visualizations to help you debug your CSS Regions.

If you’re running WebKit nightly, try out the following example I have posted on this site:

Screen Shot 2013-10-07 at 1.39.04 PMNotice the different connect text regions, interspersed with an image and some highlight text. The text flows from one connected text region to another, regardless of the size of the window, or the resolution of the device you are using to view the content.

In this example we have one DIV that defines all of the source:

<div id="source">
Far far away, behind the word mountains, far from the countries Vokalia and Consonantia, there live the blind texts. Separated they live in ...

In the CSS, we take that DIV out of the normal layout and indicate that all of the source content should flow into ‘main-thread’ by using the flow-into CSS attribute:

#source {
  -webkit-flow-into: main-thread;
  flow-into: main-thread;

Notice how we use both the -webkit- prefixed and unprefixed version of the CSS attribute.  You need the -webkit- prefix to get this to work for now, but eventually as regions become more widely implemented that will no longer be necessary.

We also have seven DIVs laid out in different parts of the page, all of class ‘region’.  In the CSS we define each of these DIVs as a region container using the flow-from CSS attribute.

.region {
 -webkit-flow-from: main-thread;
 flow-from: main-thread;

All of the source content in ‘main-thread’ will flow into the region containers. In this example, the source content is just text, but there’s no reason it couldn’t also include images, videos, iFrames, etc.

Now, normally if you want to see what’s going on in a page, you can use the Web Inspector. If you right-click on some of the text and select “Inspect Element”, the Web Inspector will pop up and show you that element:

Screen Shot 2013-10-04 at 2.58.09 PMNotice that it has taken you to the source text.

But with CSS Regions, the source content is kept separate from the actual layout.  The regions define the layout and the source content flows into the regions.  So how do we visualize the individual regions that make up a given flow?  What we really need is to be able to see how the content is going to flow from one region to the next.

If you move your mouse over each of the region containers (DIV elements of class ‘region’) in the Web Inspector, you will see the following:

Screen Shot 2013-10-04 at 3.07.59 PM


All of the connected regions in the flow are numbered (indicating the order of the regions in terms of flow) and highlighted a light blue.  Lines are drawn between each of the connected regions to show you where the next connect region is in the flow.  And finally, the currently selected region is highlighted a darker blue.

That’s definitely more useful!  In fact, if you’ve ever used InDesign, or as you saw in the Reflow video above, you’ll find that this interface will be very familiar. Now you can play with the HTML/CSS of each region or resize the page, and see how the content flowing into those region containers adapts.


There’s a great detailed article here by Christian Cantrell of the Adobe Web Platform team that discusses debugging CSS Regions in Chrome.  Remember though, CSS Regions are disabled by default on Chrome.  You need to navigate to chrome://flags and enable ‘Enable experimental WebKit features’.  As well, to get the CSS Regions debugging support in Web Inspector, you’ll also want to enable ‘Enable Developer Tools experiments’.

Let’s now try out the same example in Chrome:

You can bring up the Web inspector by right-clicking on the page and selecting ‘Inspect Element’, or pressing cmd/ctrl-I.

You can right-click anywhere in the Elements tab in the Web Inspector and you’ll see an entry for ‘CSS Named Flows…’.

Screen Shot 2013-10-04 at 3.21.56 PM

Selecting that will provide you with a list of all of the available flows and region chains:

Screen Shot 2013-10-04 at 3.23.59 PMAs you move your mouse over each of the region containers in the Web Inspector, they’ll get highlighted in the browser — very useful for debugging CSS Regions.

The tools and technology are definitely evolving.  Give it a try and let me know what you think.

Tagged , , , , . Bookmark the permalink.

2 Responses to Designing and Debugging Web Layouts With CSS Regions

  1. Pingback: Best of JavaScript, HTML & CSS – Week of October 1, 2013 | Flippin' Awesome

  2. Pingback: October 11, 2013: Weekly Roundup of Web Development and Design Resources

Leave a Reply

Your email address will not be published. Required fields are marked *