CSS regions, exclusions, shapes and new publishing paradigms
## Introduction Smashing Magazine [Newspaper Designs](http://www.smashingmagazine.com/2008/02/11/award-winning-newspaper-designs/) article shows examples of what printed media can do. Having learned to use InDesign for ePub-based ebooks I've come to respect the power and flexibility of printed media… working primarily in web environments I've always wondered what it would take to do similar layouts. Over the last year at the two [HTML5 Developer Conferences](http://html5devconf.com/) I've heard more and more about new CSS technologies that would make print-like layouts possible:Regions, Shapes and Exclusions. [Adobe](http://html.adobe.com/) has been championing these technologies, not surprising since they also create DTP and Layout programs. While these technologies (Exclusions, Shapes and Regions) are still experimental and supported by a limited number of browsers, it is still an exciting possibility for designers and developers. We can match print layouts (almost) in our web content. ## Supported browsers These technologies are still experimental and subject to change. Best place to keep up to date with the development of these CSS specs is the W3C site. Adobe may also have updated articles and tutorials. **The following browser supports the standard:** * IE, IE Mobile (-ms- flag) * Webkit nightly (-webkit-flag) * iOS (-webkit- flag) * Fully supported on iOS 7 * Chrome Canary * Enable with Enable CSS Regions flag * For Chrome 23 and later enable with: Enable experimental WebKit features * Latest Chrome Nightly uses Enable Experimental Web Platform Features to enable regions ## Can we use this for publishing projects now? While the technology is available and work to reach full recommendation status continues on the W3C's [CSS working group](http://www.w3.org/Style/CSS/) we can still play with the technology and crete prototypes. It may be a while, if ever, before ebook readers' rendering engines catch up wit the standard but let's remember that we can build web applications that will run on both Kindle Fire and iOS devices. These applications can use [polyfills](http://remysharp.com/2010/10/08/what-is-a-polyfill/) to accomplish the same or similar functionality using something like [Modernizr.load](http://modernizr.com/docs/#load) or similar loader libraries. How to do polyfill work will be explained later. ## Regions Regions allow you to create flows of content inside your web content. For those familiar with InDesign think of regions as threaded text frames that can then be laid out and changed as needed without having to change the layout of all spreads just to make one change. For those not familiar with InDesign, regions and flows look something like this:  ### Getting Started In supported browsers the code for something like the example above is fairly simple. Code First, explanation later CSS code: ```css #source { -webkit-flow-into: main-content; -ms-flow-into: main-content; } .region { -webkit-flow-from: main-content; -ms-flow-from: main-content; height:300px; border: 1px solid #f00 } ``` The `#source` element creates the flow for our regions. This text will disappear from the regular flow of text and will be placed in our regions. Every container with the class `.region` will be used to flow the text into. We can position the regions any way we want and use other CSS tools such as flexible boxes layouts, animations and transitions to place our content. Combining the HTML below: ```html
Positioned Regions
Each of the 4 regions (marked with a 1px red border) below has been positioned using CSS attributes (top and left)
Big Example Title
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vitae tempor ipsum, tempor placerat nisi. Cras feugiat est et turpis scelerisque auctor.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vitae tempor ipsum, tempor placerat nisi. Etiam vehicula lectus vel leo pharetra malesuada. Nulla risus magna, vulputate id elit quis, luctus ullamcorper ligula. Nam at faucibus massa, sed elementum tellus. Proin et dictum ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vitae tempor ipsum, tempor placerat nisi. Cras feugiat est et turpis scelerisque auctor.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vitae tempor ipsum, tempor placerat nisi. Etiam vehicula lectus
This is a test
This is a major quote for this document and we'll have to offset it from the rest of the text
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vitae tempor ipsum, tempor placerat nisi. Cras feugiat est et turpis scelerisque auctor.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vitae tempor ipsum, tempor placerat nisi. Etiam vehicula lectus vel leo pharetra malesuada. Nulla risus magna, vulputate id elit quis, luctus ullamcorper ligula. Nam at faucibus massa, sed elementum tellus.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vitae tempor ipsum, tempor placerat nisi. Cras feugiat est et turpis scelerisque auctor.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vitae tempor ipsum, tempor placerat nisi. Etiam vehicula lectus vel leo pharetra malesuada.
Nulla risus magna, vulputate id elit quis, luctus ullamcorper ligula. Nam at faucibus massa, sed elementum tellus. Proin et dictum ligula. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vitae tempor ipsum, tempor placerat nisi. Cras feugiat est et turpis scelerisque auctor.Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce vitae tempor ipsum, tempor placerat nisi. Etiam vehicula lectus
``` With the following CSS: ```css #container { position: relative; padding: 20px; border: 1px solid red; width: 90%; text-align: justify; column-count: 2; } .excluded { background: #0ff; opacity: 0.6; padding: 10px; width: 150px; height: 150px; left: 45%; position: absolute; shape-outside: rectangle(0, 0, 100%, 100%); float:left; wrap-flow: both; } ``` ## **Currently the example above Only works in IE 10 using the -ms vendor prefix** ### The final example Larger and more complex examples, including both regions and shapes are forthcoming