Getting Started with SASS for Microsoft Developers

Sass (Syntactically Awesome Style Sheets) tries to make CSS fun again.

It's a set of "extensions" on top of standard CSS that make it easier to write and maintain style sheets.

A Sass file compiles down to regular CSS so it doesn't require any special browser plug-ins.

This article is aimed at Microsoft developers but the Sass language sections apply to anyone wanting to get an overview of Sass, regardless of the web programming platform or IDE you're using.

More...

SHARE:

Redesigning DontCodeTired.Com (Part 11) - Conclusion

The redesigned Don't Code Tired is now live. This article wraps up the series with a look back at what I learned and what things are still outstanding.

Key Things I Learned

I am not a designer. Ok so I knew this anyway, even though I learned heaps from this process if I were to undertake it again I would at least get some feedback along the way from a designer.

I love SASS

CSS Media Queries are awesome. It is so easy to apply different styling based on browser width, the hard bit is deciding what you want to show

I Love SASS. SASS really does make writing CSS a more pleasurable experience. Even though I feel I have only just scratched the surface of what is possible I am hooked and will be using SASS on any project I can in the future.

Other Learnings

  • Design concepts such as: mobile-first, typography-out, designing with personality, content inventories, etc.
  • Basic colour theory
  • Controlling mobile browser rendering and zooming with meta tags
  • Custom fonts using @font-face
  • New semantic HTML5 elements
  • ARIA Landmark Roles

Evaluating the Final Design

I though it is good to look at the final outcome and compare it against what I initially set out to do.

Voice

"DontCodeTired's voice is friendly and personal, it's speech-like and somewhat casual using contractions and occasional slang over formal and stuffy speech. It doesn't try to be overly cool but is not afraid to have some fun on occasion (as long as it doesn't detract too much from the information)."

I think the the voice of the messages, prompts, navigation, etc. upholds this design goal. Some existing articles in the blog may not, but I should refer to this when writing future articles.

Colour

"DontCodeTired's colours are clean and mostly understated. Where colour highlights are needed they are saturated and bright. Solid blocks of colour are preferred to gradients."

There are no gradients in the final design, but the final colours I chose are not "understated", quite the opposite the purple is quite bright. I'm not sure how I feel at this stage, I may revisit the colour palette at a later date, but due to the awesomeness of SASS I can just change a few variables and the whole colour scheme will be updated.

Typography

"DontCodeTired is all about the article content. Main content typography will use clean readable sans-serif fonts with a predictable type ramp. DontCodeTired's overall design will be based heavily on the readability of text."

The chosen fonts meet the above brief, if I have one criticism it's that the type ramp for headings could be a little better. The first few heading levels are good, but at the lower levels there is not much difference in size.

General Style

"Taking some ques from Metro design, interface elements will mostly focus on content over chrome, elevating the article content to the fore, relegating non important navigation and other elements to the ground."

This design goal has been well respected throughout the design. There are not a lot of boxes to "constrain" content, instead proximity and relative size are used to group content.

Other Observations

  • There is too much empty space in desktop version in the header
  • The header colour may be too bright
  • Tweet button on the home page is showing the same value for each post
  • Max width should look prettier once the browser expands beyond this point, perhaps centred or other design element to fill the space
  • The SASS needs refactoring
  • Content still transmitted to mobile devices even when not shown
  • Loading speed on mobile devices needs to be quicker, especially the first page. This may need some CSS and JavaScript bundling and minification. The number of posts on the first page may also need to be reduced
  • Tag cloud and "things I've built" section need to be able to be accessed somehow on mobile devices where the sidebar is hidden

SHARE:

Redesigning DontCodeTired.Com (Part 10) - Creating the Remaining Responsive Breakpoints

Creating the Second Responsive Breakpoint

The next responsive breakpoint kicks in at 970px width. At this point the first of the sidebars become visible. This "about me" sidebar contains a basic bio and the last tweet I made, in addition to some advertisement space.

The tone of this sidebar is muted (other than the ads) with grey text and a black and white bio photo so as not to detract too much from the main article content.

I think the measure (length of horizontal line of text) becomes a little long before this break point kicks in, but is an acceptable compromise.

Creating the Third Responsive Breakpoint

The third breakpoint kicks in at 1200px. It introduces the second of the sidebars on the left side.

This sidebar contains common blog-type widgets such as tag clouds and links. Again the text is muted so as to not detract too much from the main content.

Defining a Maximum Width

As the width continues out from the third breakpoint the measure becomes increasingly long. Left unchecked the readability quickly becomes poor as the eye has a long way to travel from the end of one line on the right to the start of the next line on the left.

At some point a maximum point is reached where the text should no longer expand. This point occurs at 1470px, which still allow a pretty long measure but again is somewhat of a compromise. This is defined in the CSS using:

html {
max-width: 1470px;
}

At some point I might make the whole body centre aligned but for now I'm ok with this.

Using SASS to Style Tag Cloud Text Sizes

The blogging engine I'm using renders the tag cloud by adding classes to the items depending on the prominence of those tags in posts. Whilst I could have simply hard-coded the font sizes in these, it looked like a good opportunity to use SASS.

First I defined a couple of SASS variables, one to set the base font size for the least frequent tags, another to set what the increment is between each size. Then it's just a matter of multiplying the base size by a multiple of the increment. This enabled me to play with different combinations really quickly to get the look I wanted.

The final chuck of SASS looked like this:

$tcBaseSize: 0.5;
$tcIncrement: 0.3;
.tagcloud a.biggest {
@include font-size($tcBaseSize + (4 * $tcIncrement));
}
.tagcloud a.big {
@include font-size($tcBaseSize + (3 * $tcIncrement));
}
.tagcloud a.medium {
@include font-size($tcBaseSize + (2 * $tcIncrement));
}
.tagcloud a.small {
@include font-size($tcBaseSize + (1 * $tcIncrement));
}
.tagcloud a.smallest {
@include font-size($tcBaseSize);
}

Styling the Bullet Points in Unordered Lists

I wanted to change the bullet points from the default black circle to a coloured square as a nice visual embellishment.

The problem is that other than using images for bullets, this can be hard to do in CSS. Also I needed the solution to work with all the old posts that used unordered lists.

The solution I came up with (whilst a bit of a hack) seems to work nicely with the above constraints.

The solution involves using some jQuery to find all the <li> elements, and inject a <span> to wrap the inner content. This span has an inline style applied to set the colour to the that used by the rest of the article copy.

function wrapListItemContent() {
var standardTextColor = $("#hiddenTextColorJQueryHook").css("color");
$("ul li").each(function () {
var t = $(this);
t.html('<span style="color: ' + standardTextColor + '">' + t.html() + "</span>");
});
}

The hiddenTextColorJQueryHook is an element that I inject whatever SASS colour variable I'm using, so that if I change the SASS colours there will be no change required in the JavaScript.

The downside of this approach is the bullet points and text will appear coloured until the jQuery document ready fires. I may decide to pull this once I get into final device testing.

Screenshots of the New Breakpoints



SHARE:

Redesigning DontCodeTired.Com (Part 9) - Creating the Design for the First Responsive Breakpoint

At this point in the redesign process the mobile layout and design is (mostly) complete. The next stage of the process is to look at "non-mobile" designs.

Again I am going to take a typography-first approach. What this means is looking at the font size, measure, etc. at different browser widths and trying to maintain a nice reading experience as the width increases.

Responsive Breakpoints

A response design breakpoint is that point where one set of CSS styles takes over from another. Each breakpoint represents potentially different layout, styling, content and functionality. Responsive breakpoints are implemented using CSS3 media queries that enable a different set of CSS to be applied depending on the size of the window.

A response design breakpoint is that point where one set of CSS styles takes over from another.

As I am thinking typography-first, I will let the breakpoints occur naturally where they arise rather than designing up front. I'll be doing in-browser design rather that mockups in a drawing or prototyping application.

A good guide (see below for recommended tools) for the different resolutions is the Chrome Window Resizer plugin.

Will it Look Good on an iPad?

It's not a good idea to think of individual devices because we don't want to have device-specific renderings; this is not sustainable or maintainable: every time a new device is released we would have to create a breakpoint for it.

If the user has a browser that supports media queries then we can write CSS specifically for certain situations

We can however look at the resolution of an iPad (for example) and add this to the Window Resizer plugin to give us another useful reference point. I have added a 1024 x 768 (iPad landscape) and 768 x 1024 (iPad portrait).

Arranging the CSS (SASS)

Currently I have a 0-up.scss SASS file that generates a 0-up.css file. This is being included and is not surrounded by a conditional media query. This means that these styles will always be used, unless they are overridden by styles that occur later in the CSS.

The styles that are specified later on will be surrounded by media queries that represent the responsive breakpoints in the design.

The First Responsive Breakpoint at 768px

At 768 pixels wide the measure (of the text) is still nice as is the font size. The thing that I want to introduce at this breakpoint is a change in the header.

I want to replace the drop-down select box with simple hyperlinks. I also want to add the search box into the header.

Creating a Breakpoint Using CSS Media Queries

The first thing we need to do is create a new (SASS) stylesheet to represent the styles that will be overridden, i.e. 768-up.scss.

The first thing in this stylesheet is to create the media query:

@media all and (min-width: 768px){
}

Weirdly, the Chrome Window Resizer seems to incorrectly report the width so at 768px the media query didn't kick in (I testing this by adding html { background-color: black;} and using the plugin to change to 768px, but the background was still white.

Some other tools I tried:

Hiding the Drop Down Select Menu

In the 768-up file:

@media all and (min-width: 768px){  
#menuNavSelect{
visibility: hidden;
display: none;
}
}

Showing the Hyperlink Navigation

In the 768-up file:

@media all and (min-width: 768px){  
#menuNavSelect{
visibility: hidden;
display: none;
}
#menuNavList {
visibility: visible;
display: block;
}
}

Showing the Search Box

It's at this point that the idea of having multiple SASS files to represent the breakpoints becomes problematic. The problem is that if we want to use any of the mixins or variables that are defined in the 0-up.scss file we would have to copy and paste them creating a maintenance overhead.

There is an import rule is SASS that can import another .scss file but it looks like it imports as plain CSS if there are any media queries.

So rather that have separate SASS files for each breakpoint, I've decided to have one SASS file, inside which all the media queries will be defined.

To show the search box, in the 768-up section of the scss file we add some styling for headerSearchContainer:

@media all and (min-width: 768px){  
#menuNavSelect{
visibility: hidden;
display: none;
}
#menuNavList {
visibility: visible;
display: block;
}
#headerSearchContainer {
visibility: visible;
display: block;
}
}

These are the only changes I want to make at this breakpoint. I may makes some tweaks later, but for now this is fine.

 







 

Screenshots from the awesome Responsinator












SHARE:

Testing Responsive Web Designs and Layout

CSS3 Media Queries enable us to have different layouts and show/hide content based on the width of the browser or device the page is being displayed on.

Typically you will have a number of Responsive Design Breakpoints that say something like: "when the screen width is less than 800px hide this, otherwise show this... etc". So we need some way to test how the page will look at a given width.

During the (ongoing) redesign of DontCodeTired I needed a way to test the site at different screen widths.

I tried a number of different tools, the two below are the ones that worked the best for me:

Firefox Nightly

Firefox Nightly is a pre-release version of Firefox for testing purposes only. It has a new awesome feature called Responsive Design View that will hopefully make it into the 'real' Firefox one day.

After you install, go to Tools -> Web Developer -> Responsive Design View. This will enable you to resize the 'internal' window to a custom size, or choose from one of the presets. The image below shows  a locally running website at 320x480:

 

 

The Responsinator

Apart from having an awesome name, The Responsinator is a website that allows you to visualise how a page will look on a given number of harware devices such as iPad, "Crappy Android landscape", etc. It's a nice tool tool to get a high-level overview at points throughout the design process but it's probably not as good as Firefox Nightly for quick testing. It also doesn't allow custom sizes, but it's still a great tool for visualisation. You can also use it with local or remote sites. The image below shows The Responsitator showing a local site (I've zoomed out the browser so you can see more devices): 

 

 

Some Other Tools

SHARE:

Redesigning DontCodeTired.Com (Part 8) - Visual Styling

Now I have all the elements in place (semantic HTML5, typography, copy) in place I can start to think about the visual styling and decoration.

The first thing is to refer back to the initial Design Persona Visual Lexicon:

"DontCodeTired's colors are clean and mostly understated. Where color highlights are needed they are saturated and bright. Solid blocks of color are preferred to gradients."

Bearing this in mind I came up with a list of style attributes that I want the visual design to posses:

  • light
  • spacious
  • digital
  • clean
  • crisp
  • bright
  • saturated color
  • open
  • simple

Choosing a Color Scheme

This step is about creating a set of colors that will work together in the design.

Color is a powerful tool that will set the overall tone of the site. There is a whole psychology of color which I would love to learn more about, but this color wheel gives a good idea, what's really interesting is the cultural-specific attitudes to colors.

Looking back at the brand traits from part 2:

  • knowledgeable but not condescending
  • clear but not elitist
  • valuable but not limited
  • friendly but not chatty
  • honest but not mean

As we want a sense of friendliness, the first color to rule out are the reds. Reds signal danger (for example blood is red) so it's a very strong color and according to the color wheel is also associated with aggression.

The knowledgeable and honest traits suggest pinks (truth), purples (wisdom), blues (wisdom) and browns (credibility). Comparing these candidate colors to the style attributes above (particularly bright and saturated) rule out the browns.

The honest brand trait leads us to pinks (truth), yellows (honor) and again browns (credibility).

So, in addition to black (which I have already decided for the main article content) and white (for the background), I have the following candidate colors:

  • pinks
  • purples
  • blues
  • yellows

Using a tool like Kuler I can now start to put together some color swatches.

Below is an initial attempt at some color schemes:

 

Interestingly, when playing with the different color rules some of the colors I had thought not to use appeared, such as browns and greens. I think it's important to remain open-minded throughout the design process so it's ok to explore variations.

In the case of the greens I think this still fits into the overall feel I'm trying to create and the greens bring a sense of nature to the design. This natural feeling is somewhat at odds with the digital style attribute I outlined above, however I think the 2 can co-exist and the greens may offer a nice counterpoint.

I especially like the first and third schemes in the above image, however I don't think the first one offers enough contrast. I tried adding a green and slightly changing the hue/saturation of the others to get this:


  

Whilst there is a bit more contrast in this it still doesn't feel right. I know that is a very non-technical description, and I'm sure I have violated numerous color rules, but it doesn't feel very integrated and feels to me somewhat confronting or distant or disingenuous.

So I went back to scheme three and tried adding a purple into it:

Again this didn't seem right to me and scheme three kept calling out to me for some reason, so although I tried different permutations I'm going with my gut feel:

Using SASS to Define Colors

The awesome SASS let's us define variables, which includes variables to represent colors.

Defining Basic Background and Foreground

The first colors that need defining are the default background and foreground text. The background will be pure white, with the foreground text being an almost-black (to soften and slightly reduce the contrast) and make text a bit easier on the eye)..

$primaryContentBgColor: #FFF;
$primaryContentTextColor: #333;
html {
background-color: $primaryContentBgColor;
color: $primaryContentTextColor;
}

All Monitors Are Not Equal

Up until this point I've been using an Acer monitor plugged into my Lenovo X220T as my main screen for Kuler and playing with colors. An interesting thing happened why I viewed the colors on a physical Windows phone and on the laptop monitor. The colors were really different, with what I though were purples coming out as pinks.

This again highlights the importance of testing on actual devices early on.

Ideally I would calibrate all my screens with a hardware colourometer such as the Spyder. Obviously this would be basic requirement if I were a professional designer...

This is what the final color palette looks like when adjusted from my laptop screen and checked on a physical phone:

Defining The Other Colors

Up until this point I've mostly been doing in-browser design, i.e.using HTML and CSS to create wireframes\mockups. This enables early feedback of any potential browser problems and means that rendering of text is more realistic than if a graphics program is used.

At this point it makes some sense to open up an image editor (for example the free Paint.NET and throw around some colors. I added in the Kuler colors into Paint.NET palette as custom colors and then played around with different combinations just to get an initial feel for how I wanted to use the 5 colors, plus black and white.

Out of these three color concepts I've chosen to go with the right most one initially. The great think about using SASS color variables is that it's going to be super easy to change colors if I change my mind later.

Designing a Logo

So now I have a color concept I can think about a logo. I am not a graphic artist, so I am going to stick with a basic text-based logo which will work out better for everyone concerned.

To allow me to 'generate' logos at different sizes with no loss of quality I need to use a vector based format, rather than bitmap format. The free Inkscape allows creation and saving of vector based images in SVG format. The added advantage is that I might choose to use a native SVG file in the browser rather than rendering down to a raster image like a PNG.

Some initial design ideas:

Out of these I picked the one I liked the most and started to play with some theme colors:

The Finished Mobile-First Design

I consider the mobile design to be (mostly) complete, here's how it looks in Windows Phone emulator:

 





  

SHARE:

Redesigning DontCodeTired.Com (Part 7) - Brand-Aligned Wording

In part 2 I created a Design Persona that describes what "personality" the redesigned blog will have.

Part of this design persona involved defining some brand traits:

  • knowledgeable but not condescending
  • clear but not elitist
  • valuable but not limited
  • friendly but not chatty
  • honest but not mean
  • avoid: shallow or poorly written content

In addition I thought about the "voice":

"DontCodeTired's voice is friendly and personal, it's speech-like and somewhat casual using contractions and occasional slang over formal and stuffy speech. It doesn't try to be overly cool but is not afraid to have some fun on occasion (as long as it doesn't detract too much from the information). "

This step of the redesign involves looking at the messaging throughout the site (error messages, prompts, button text, etc.) and aligning it to the design persona.

Some Examples

The following are some examples of content that I changed:

  • "Contact" to "Say Hi"
  • "Related posts" to "Posts you might like"
  • "Comments are closed" to "Sorry, comments are closed."
  • "Comments" to "Have your say"
  • "Required" to "You missed this"
  • "Let me know when a new comment is added" to "Send me an email when new comments are added"
  • "Send" to "Send message"
  • "I suggest you try one of the links below" to "Try one of these"
  • "Tag" to "Tagged as"

I think that changes like these can subtly enhance the friendly feel of the site.

I may end up tweaking these a bit more but for now I am happy with it.

SHARE:

Redesigning DontCodeTired.Com (Part 6) - Creating Mobile Styling Using a Typography-Out Approach

Redesigning DontCodeTired.Com Part 5 - Showing and Hiding Mobile Specific Elements

The idea of typography-out is that for websites where the textual content is king, it makes sense to elevate it to the thing of primary importance. The thing that drives the rest of the design. The opposite approach is to focus on the canvas as the first thing and work "inwards' to get to the content (text) last (putting "style" or "decoration" or "chrome" before content).

Letting Typography Lead the Design

What I mean by this is the way the article text fills the screen on the mobile emulator: how many characters\words per line (i.e. the measure), leading, font size, typeface choice. All of these basic typogographic principles (of which I am not an expert) will be applied to make the content readable. Above all, readability is the primary consideration.

(Starting to learn more about typography (and other aspects of design) has given me insight and great respect for professional web designers...)

I'll consider reading distance (how far people are likely to be from the screen) as this informs the choice of font size, etc. For tablet\desktop usage, the font size may need to be different to accommodate different physical reading distances.

Choosing a Typeface

The CSS3 @font-face rule allows us to use typefaces that are different from the standard web-safe fonts. It allows us to reference new fonts to use on our sites by loading a font file into the browser and then referencing it in the CSS.

There are (as with anything Web related) different formats (WOFF, EOT, TTF/OTF, SVG) that different browsers support. The awesome Font Squirrel makes it easy to generate the CSS - and they have a load of "commercial-use free fonts".

I chose PTSansRegular for body and PTSerifCaptionRegular for headings, generating the @font-face and downloading multiple font format files courtesy of the awesome FontSquirrel. For the less important elements such as the published time I chose PTSansNarrowRegular.

Setting up the fonts

FontSquirrel generates a stylesheet.css which contains the @font-face definitions. This file sets the font-weight and font-style to normal for each of the included fonts.

This can cause a problem where text will be doubly emboldened or italicized. For example, if the <em> style below is used, the browser may try to initializes an already italic typeface and you may get horribly double slanted (italicized) text:

em {
font-family: 'PTSansItalic', Georgia, serif;
}

To fix this we can edit FontSquirrel's CSS and specify font-style: italic; in the font-face:

@font-face {
font-family: 'PTSansItalic';
src: url('PTS56F-webfont.eot');
src: url('PTS56F-webfont.eot?#iefix') format('embedded-opentype'),
url('PTS56F-webfont.woff') format('woff'),
url('PTS56F-webfont.ttf') format('truetype'),
url('PTS56F-webfont.svg#PTSansItalic') format('svg');
font-weight: normal;
font-style: italic;
}

(You can do this for bold typefaces too..)

A Nice Vertical Flow

We want the vertical flow of text to look good. One way we can do this is to space things vertically in a consistent way.

The rem unit of measurement is a newer CSS concept with some support. It is similar to em in that it is a relative measurement, but unlike em it is relative to the root HTML element rather than the element's immediate parent.

As rem is not supported in older browsers we can specify a px value first and then a rem value. This could be pretty tedious, but again SASS makes it less painful.

The following extract of SASS defines some variables and a mixin to set basic typography properties:

/*
Variables
*/
$baseFontSize: 16; // size for px values and rem calculations, i.e. 1 rem = this value
$lineHeightMultiple: 1.5; // e.g. 1.5 = 150% line height
$baseVerticalRhythm: $baseFontSize * $lineHeightMultiple;
@mixin standardTypeMeasure($multipleOfBaseRhythm){
$px :$baseVerticalRhythm * $multipleOfBaseRhythm;
font-size:  $px + px;
font-size: $px / $baseFontSize + rem;
line-height: ($px * $lineHeightMultiple) + px;
line-height: (($px / $baseFontSize) * $lineHeightMultiple) + rem;
}

This mixin can then be called from our CSS rules:

time {
@include standardTypeMeasure(0.5);
font-family: 'PTSansNarrowRegular', Georgia, serif; 
}

This results in the following generated CSS:

time {
font-size: 12px;
font-size: 0.75rem;
line-height: 18px;
line-height: 1.125rem;
font-family: 'PTSansNarrowRegular', Georgia, serif; }

Browsers that do not understand rem will instead use the `px' value.

Investigating CSS Hyphenation

I experimented with CSS text justification and hyphenation but it didn't look great and current browser support at the time of writing is only 24.77%. I was testing in Firefox using the vendor prefix :

text-align: justify;
-moz-hyphens: auto;

A Nice Chrome Plugin

There is a nice Chrome browser plug-in which quickly lets you change the browser window to one of a number of preset sizes (e.g. iPhone, iPad etc.) or create your own.

For the mobile version I've been mostly using the Windows Phone 7 emulator, however this Chrome plugin will be great for future parts of the redesign.

In Conclusion

Throughout this section I've also been continuing to hide elements that are not good for mobile. I've also been fixing up bits of markup (for example on the add comments section) to make it easier to style.

At this point I'm still not thinking about non-typography elements such as decoration, colors, logos, etc. This part will come later (and is going to be heaps of fun).

This step took a lot longer than I thought it might, but I'm OK with that as one of the goals of this redesign is to focus on the text.

Screen Shots



SHARE:

Redesigning DontCodeTired.Com (Part 5) - Showing and Hiding Mobile Specific Elements

Taking a "mobile-first" approach, the initial work on styling will be for mobile devices, i.e. small screen resolutions.

Getting Started

In a previous post in this series I added the semantic HTML5 elements.

I'm going to be using SASS from this point onwards to generate the CSS.

I have taken a copy of the blog and hosted on my local machine, this means I can work with real content (blog posts) and hopefully encounter any problems much sooner than I could with fake Lorem ipsum text.

In the master page I have removed the reference to the existing style.css and replaced with a reference to 0-up.css. This file is essentially the 0-width-and-up CSS that will be rendered on mobile devices, eventually media queries will kick in to override these styles on desktop\tablet browsers.

The 0-up.css file is not edited by hand, instead it is compiled from the 0-up.scss SASS file.

What the site looks like naked:

dontcodetired.com without any styling CSS

Hiding the Side Bar

So now we have some semantic HTML5 markup and an unstyled site (other than some CSS base/reset styles). The next step is to hide items such as the widget side bar that contains tagcloud, etc.

There will be times throughout the redesign that specific elements will need to be hidden, I've created a mixin. I can then just apply this mixin in any CSS rule.

The following is an extract from the 0-up.scss which shows a mixin being defined and then applied to hide the sidepanel div:

/* based on visuallyhidden style from http://html5boilerplate.com/ */
@mixin visually-hidden {
border: 0; 
clip: rect(0 0 0 0); 
height: 1px; 
margin: -1px; 
overflow: hidden; 
padding: 0; 
position: absolute; 
width: 1px; 
}
#sidepanel {
@include visually-hidden;
}

Different Main Navigation for Mobile

The first step is to hide the existing "desktop" nav by applying the above mixin:

#menuNavList {
@include visually-hidden;
}

(gotta love SASS!)

Next we need to render some new markup that will display a drop down box for a the main menu navigation, this will take up less space on mobile devices and the select behavior will be in line with the mobile device on which it's rendered (for example on Windows Phone the full page list picker would be shown).

<select id="menuNavSelect">                
<option value="<%=Resources.labels.home %>"><%=Resources.labels.home %></option>
<option value="<%=Resources.labels.archive %>"><%=Resources.labels.archive %></option>
<option value="<%=Resources.labels.contact %>"><%=Resources.labels.contact %></option>
<option value="<%=Resources.labels.subscribe %>"><%=Resources.labels.subscribe %></option>
</select>

This new menu doesn't have to be explicitly set to visible. As this is a mobile-first design approach, at the moment I'm not worrying about desktop versions. Future work will involve creating media queries for higher resolutions that may hide this new menu and make the original menu visible again.

This approach is continued for the other HTML elements, in some cases more appropriate markup is rendered just like the navigation above.

SHARE:

Redesigning DontCodeTired.Com (Part 4) - Adding Semantic HTML 5 Markup and Removing Unwanted Elements

Redesigning DontCodeTired.Com (Part 3) - Creating Content Reference Wireframes using Mobile-First Responsive In-Browser Design

Adding New HTML5 Semantic Tags

DontCodeTired.com is currently using the open source BlogEngine.Net. The markup that is currently rendered uses divs for organizing content and layout. HTML 5 gives us some new semantic elements that can give greater meaning to the content. While there seems to be differing advice in the exact usage of some of these elements, for now I'm doing what I think makes the most semantic sense for my content.

The following new HTML 5 tags have been introduced to the markup:

<header> which also contains the main site navigation in a child <nav>

<article> now surrounds each individual blog entry.

All <article> elements are surrounded in a common <section> to differentiate the articles from the sidebar content which is also in a <section>.

Each <article> now has it's own <footer> and <header>. These two new elements can appear multiple times on a page. The header contains the post title and publish date. The footer contains the social bookmarks, post rating etc. (The social bookmarks used to be contained in a <div>, this has now been changed to a <section> as the content is "thematically related"). Note: the new <section> element should not be used to replace all <divs> especially those divs which are used purely for layout, etc. Instead it should be used to give semantic meaning to the content it contains.

Each right-hand widget (tagcloud, recent posts, etc) is contained in a <section>. I considered using an <article> or <aside> instead of a <section> but these tags didn't seem quite right, I may change them in the future once HTML5 adoption increases and common usage patterns emerge.

<footer> for page footer.

<time> element to represent the publication date of the blog entry, e.g. <time pubdate="pubdate" datetime="2012-04-25T14:22:00">Wednesday 25 April 2012 14:22</time>

Note: the pubdate="pubdate" is the XHTML5 variant, you could also use: <time pubdate datetime="2012-04-25T14:22:00">Wednesday 25 April 2012 14:22</time>

Coining a Term - Semantic Structure Wireframe

So I came up with this idea of a Semantic Structure Wireframe. A Semantic Structure Wireframe is an outline of how content is broken down and organized semantically using the new HTML 5 tags. It is meant to be a high level view of the blocks of semantic content the will be represented on the page.

An example of a Semantic Structure Wireframe for the DontCodeTired.com page viewing a page with multiple blog posts: 

Semantic Structure Wireframe

To enable older browsers to be able to recognize and style these new HTML5 tags, I'm including HTML5 Shiv. Similarly as I will be using CSS 3 media queries to create a responsive design I've also included Respond.js to add CSS 3 min/max-width media query support to older browsers. These 2 files are actually included as part of a custom build, in additional to things like Modernizr created at initializr.com). The Initializr package also contains some HTML5 compatible CSS reset styles which I've also included.

Removal of Unwanted Elements

Some elements that I no longer wanted were also removed at this stage - these are things that I don't want on any device or screen resolution:

  • 'filter by APML' link
  • log in/out link in main menu when logged out - appears only when logged in
  • "by Jason" on each article - as I'm the only one that posts it's redundant :)

Adding ARIA Landmark Roles

The Accessible Rich Internet Applications specification allows authors to add additional 'metadata' in order to "to allow assistive technologies to convey appropriate information to persons with disabilities". This helps assistive technologies (such as screen readers) to better understand and navigate content. The Landmark Roles "are regions of the page intended as navigational landmarks". These roles can be used in addition to HTML5 semantic markup.

The following Landmark Roles have been added to DontCodeTired HTML5 elements:

  • <header id="header" role="banner">
  • <nav id="menu" role="navigation">
  • <article role="article">
  • <footer id="dctMasterPageFooter" role="contentinfo">

Screenshots of desktop and wp7 at this stage (note some formatting has broken i.e. right hand widgets don't have backgrounds anymore), this will be fixed when we come to do the styling.

 

screenshot of desktop browser

screenshot of Windows Phone 7 Browser

SHARE: