Useful links: media queries, IDs, 24 Ways

Cross-Browser Retina/High Resolution Media Queries. Brett Jankord has some suggestions for improvements on the current way of working with media queries for high res devices.

IDs will not make your document more semantic by Louis Lazaris  is a response to a couple of previous authors on the question of ID use. He links to the previous articles and has an update at the end about one of the articles. Interesting semantic discussion.

Just in case you hadn’t realized it’s December, a little reminder that 24 Ways is publishing again. Today’s post is about accessibile color.

Keep it Clean: Your Blog and Clean HTML

I frequently work with content that gets moved from one place to another. Sometimes I get guest posts here on Web Teacher that have to be formatted from one source or another into WordPress. Most often, however, I work with content from a BlogHer network blogger who is putting content from their own blog on BlogHer.com.

Sometimes it can take me as long as a hour to clean up the HTML that gets pasted in from one blog to another. It is possible to write clean HTML in a blog, but it doesn’t always happen.

Why is Clean HTML Desirable?

  • It moves easily from one place to another and looks good in both places.
  • It doesn’t have a lot of inline styles that worked on one blog, but don’t make sense anywhere else.
  • It fits right in with the look and feel of its new location, because the HTML is uncluttered with presentational information.

What is Clean HTML?

Clean HTML is the bare essentials. It is content with just the tags that format it as headings, paragraphs, lists, etc. There isn’t any style information added to the tags about alignment or margins or text colors. Here is an example of clean HTML.

clean html

Clean HTML is content formatted with an appropriate HTML tag that describes the content. The example above has some paragraphs, a couple of headings, and some links. The tags (p, h3, a) describe exactly what the content is semantically. There is nothing added to the HTML that affects alignment, spacing or anything that is related to the appearance of the content. There’s another name for clean HTML. It’s called POSH, or plain old semantic HTML.

Here’s an example of HTML that is not clean or semantic.

not clean

In this example, the tags do not describe the content. A div is a generic container, so we don’t know if what is enclosed in the div is a paragraph or something else. The style rule in every div should not be in the HTML at all. Style rules belong in the style sheet, not the HTML. When you move that blog post with its added style rules to another blog, the styles in the HTML may be completely inappropriate in the new location. It’s okay to have a class assigned to an element in your HTML, it that class is really needed. In this example, I don’t think it is. Both the class and the style rules could be eliminated by formatting the text properly as paragraphs.

How Can a Blogger Keep the HTML Clean?

A big part of it is what you touch and what you don’t touch.

I’ve outline items you do touch regularly in WordPress in this image. Other blogs look approximately the same.

do touch

  • Use the media icons to upload media.
  • Use the B icon to create <strong> tags for strong emphasis. This normally makes the text display in bold and somewhat larger. Just because it’s bold and a little larger that does NOT make it a heading. It only makes it have strong emphasis.
  • Use the I icon to create <em> tags for emphasis. This normally makes the text display in italics. Just because it’s in italics that does NOT make it a book or newspaper title, nor does it make it represent a foreign language. It only makes it emphasized. See the note on bold and italic in the next section.
  • Use the Paragraph menu to format paragraphs. The pull down menu by the Paragraph also allows you to create headings from h1 to h6. Something formatted with an h1, h2, h3, etc. is a real heading.
  • Use the list icons to create lists. You can make something that looks like a list out of a paragraph with line breaks, but it’s not a list – it’s a paragraph.
  • Use the link icons to create links.
  • Use the quote icon to create a blockquote.

Touching the other icons, such as the alignment icons or the color and size icons generally add unwanted style rules to your HTML.

The indent and outdent icons will create a blockquote if you apply it to text. (Use the quote icon if you want a blockquote.) The indent and outdent icons are for making nested lists.

What if I Actually want Bold or Italic?

There are tags that create text that is either bold or italic. They are the <b> and <i> tag sets. If you actually want something to be bold instead of <strong> or italic instead of <em> you can do it in the HTML pane of your blog. The HTML button is in the upper right corner of your blog post window. When you click it you see the HTML you’re creating.

HTML pane

You can type anything you want in this window. HTML works with opening and closing tags that turn formatting on and off. So <b> says start bold here. Then </b> says stop the bold here.

Suppose you wrote this sentence:

I love my dog, Buster.

If you want the word Buster to be bold, click into the HTML pane, find the word Buster, and put the; tags around it, like this:

I love my dog <b>Buster</b>.

You can do the same with book titles or foreign words using the <i> tag.

How Often are you “Fixing” the Appearance of your Posts?

If you find yourself fussing around with margins or borders around images, or the colors of text, or the alignment of text and images, or the spacing between things each and every time you enter something in a blog post, then you are muddying up the HTML. Appearance should be taken care of in the style sheet. The blog post window should be used only to enter content. All those things you fuss with can be in the style sheet so they can apply every time you insert an image or create a heading.

I’m not going to explain how to modify your CSS rules in this post, but I may write a separate post about it at some point. I did talk about how to hunt down the rule you need to modify in the CSS in a presentation from 2009.

Less fussing with appearance is really the key. Making your style sheet do all the fussing for you is the goal. Then you won’t need to do anything with your post but add the content and mark it up with the proper formatting using semantic tags for headings, paragraphs, lists, images, and blockquotes.

Announcing Web Platform Docs

A great new resource for learning web design was announced at webplatform.org. It’s a wiki and participation by knowledgeable web designers and developers is needed. That said, it’s already a huge resource of the best information available.

Congratulations to everyone involved in this effort. The group calls itself the Web Platform Stewards, and includes

  • Adobe
  • Apple
  • Facebook
  • Google
  • HP
  • Microsoft
  • Mozilla
  • Nokia
  • Opera
  • W3C

Paul Irish has a lot of good ideas about how you can contribute to the site in Why I’m So Excited about Web Platform Docs.

The Proposed Picture Element in HTML

New at the W3C is a proposal to create a way to work responsive images. The proposal, called HTML Responsive Images Extension, suggests a new HTML element called <picture>. The editors of the document are Mat Marquisa member of the  Responsive Images Community Group and Adrian Bateman from Microsoft Corporation.

The document is a draft, which means many things may change before these suggestions become a recommendation at the W3C.

The reasons and goals for the proposed element are spelled out:

  • Respond to different screen pixel width/height
  • Respond to different screen pixel densities
  • Respond to user zoom on image resource.
  • Provide user agents with information they need to select the most appropriate image source given low bandwidth situations
  • Will fallback gracefully on older user agents
  • Can be polyfilled effectively
  • Retains, at a minimum, the same level of accessibility as current img element
  • Preserves separation of content markup and styling
  • Provides a purely client-side solution which can include JavaScript, but doesn’t require it
  • Supports use cases where authors need to explicitly define different image versions as opposed to simply different resolutions of the same image
  • Provides a consistent and predictable pattern for delivering alternate media sources based on client context
  • Supports succinct but understandable mark-up

A lofty list of goals, all necessary and important. Responsive design gurus have struggled for some time with how to deal with images in a responsive site. The list of goals reflects that discussion and those needs.

The proposal states, “The picture element represents a list sources of image data and associated attributes that define when an image should be used. Image data sources may be explicitly declared based on media queries or can be suggested to the browser via the srcset attribute on the picture element.”

Here’s some example code.

<picture alt="">
	<source media="(min-width: 45em)" 
 srcset="large-1.jpg 1x,large-2.jpg 2x">
	<source media="(min-width: 18em)" 
 srcset="med-1.jpg 1x,med-2.jpg 2x">
	<source srcset="small-1.jpg 1x, small-2.jpg 2x"> 
	<img src="small-1.jpg"> 
</picture>

New elements and attributes you’ll notice in the example code include the source element and its srcsetattribute. Each source defines one or more image sources and the conditions under which that source should be used. The srcset attribute is a comma separated list of URLs for alternate resources for a single image at different resolutions.

You see a 1x or 2x designation after the image name. This is a reference to resolution, with 2x being a high resolution image meant for high res (aka iOS retina displays which have made everyone’s images look like crud) devices.

Finally, the example code ends with a fallback img element for devices that don’t recognize the picture element.

Suggestions for how alt text should be handled have not changed and would apply to picture as they currently apply to img.

There is an attempt to describe cases like zooming, whether a device is displaying in horizontal or vertical orientation, and other potential snafus. You can read these in the full proposal.

Useful links: Mobile first, Google search results, design problems

The Many Faces of Mobile First is thought provoking read. The photos used in this article are powerful as well.

An Update to Our Search Algorithms on the Google blog explains that search results will now take into account the number of valid copyright removal notices  for any given site. Google says, “Sites with high numbers of removal notices may appear lower in our results.”

Top responsive web design problems – and how to avoid them is in .net magazine by James Young.

Useful links: Prism, Lea Verou, multimedia troubleshooting, $5

Lea Verou has released her syntax highlighters prism.js and prism.css as a free download.

A side note about Lea, she has just joined the W3C as a member of the the W3C developer relations and web education teams. If you are working in web education, perhaps you should find out a little about her if you don’t already know who she is.

HTML5 Doctor has an article to help you with Multimedia Troubleshooting.

An expose from .eduGuru about potential problems in the EDU world: Are You Being Used?