You are viewing the Articles in the Browsers Category

CSS3 Attribute Selectors

The power of CSS Selectors can not be understated; for, without them, there would be no simple means by which developers could target specific elements for styling in a manner abstracted from, or external to, the actual markup to which the styles will bind.

In addition to some of the more common Simple Selectors, such as Type Selectors, Class Selectors and Id Selectors, we have have Attribute Selectors, which, as the name implies, allow us to match elements based on their attributes.

Attribute Presence and Value Selectors

CSS2 introduced four Attribute Selectors; referred to as Attribute Presence and Value Selectors, which allow for coarse grained matching of specific elements based on their attributes and / or attribute values. These include the following:

e[attr]
Where e is an element and [attr] is an attribute of element e. For example, p[title] would match all p tags with a title, regardless of the value of the title.
e[attr=val]
Where e is an element and [attr=val] represent an attribute of element e which contains the exact value of val. For example, p[title="Example 1"] would match all p tags with a title which equals “Example 1” exactly.
e[attr~=val]
Where e is an element and [attr~=val] is an attribute of element e which has a value containing a whitespace-separated list of words, one of which equals val exactly. For example, p[title~="Example-1a"] would match all p tags with a title containing the word “Example-1a” in a list of whitespace delimited words.
e[attr|=val]
Where e is an element and [attr|=val] is an attribute of element e that has a value of val exactly, or begins with val immediately followed by a hyphen “-“. For example, p[title!="Example"] would match all p tags with a title containing the word “Example-“, followed by any other value, such as “Example-1”, “Example-A”, etc..

View Example

Substring Matching Attribute Selectors

In addition to the above Attribute Presence and Value Selectors, CSS3 expands on this by defining three additional Attribute Selectors; referred to as Substring Matching Attribute Selectors. These additions allow for fine grained matching of specific elements based on their attribute values.

In simplest terms, the new Attribute Selectors in CSS3 can be used to match an element with a given attribute whose value begins, ends or contains a certain value. The following is a basic description and example of each new Attribute Selector:

e[attr^=val]
Where e is an element and [attr^=val] is an attribute of element e which contains a value that begins with val.
e[attr$=val]
Where e is an element and [attr$=val] represent an attribute of element e which contains a value that ends with val.
e[attr*=val]
Where e is an element and [attr*=val] is an attribute of element e which has a value that contains val.

View Example

To summarize, there are a total of seven Attribute Selectors in CSS3, three of which are new. Whether used for general matches, such as global Attributes; e.g. *[hreflang|=en] or more specific matches, such as chaining; e.g, a[href^="https"][target="_blank"], Attribute Selectors provide a powerful mechanism for selecting both general and specific content within a page.

Interconnectivity in JavaScript with Peerbind

The ability to facilitate interconnectivity between multiple clients has always presented some rather interesting possibilities for both simple and complex Web Applications alike. More often than not, such interconnected applications would require complex server-side configurations (often proprietary in nature) in addition to numerous infrastructure considerations.

Peerbind, a new JavaScript API, remedies many of these complications by providing a very simple client-side API built on jQuery.

Peerbind is quite unique in that it provides an event binding API (on top of jQuery) that is shared amongst all connected clients of the same interest. Essentially this allows for binding something as common as a “click” event (or any event for that matter, including custom events) such that each active instance of the same application across the web will be notified of the event. As one might imagine, this allows for some rather compelling possibilities.

To demonstrate just how quickly and easily interconnectivity can be plugged into a web application using Peerbind (and the Peerbind public server), below is a simple example which displays a new item each time a new “peer” views the example page since loaded (hint: try opening a few instances, either in tabs or separate browsers).

Example (run)

Simple enough!

Of course, for most applications there are obvious security concerns which would need to be addressed as well as issues of scale and availability to take into consideration. That being said, if you haven’t checked out Peerbind yet and would like to quickly and easily add interconnectivity to your application or leverage it’s simplicity to prototype such features, it is certainly worth taking for a test drive.

Tracking HTML5 Support in Chrome

Google has now made it easy to track the current implementation status of HTML5 in Chrome via The Chromium Projects’ new Web Platform Status page.

Many of the sections have links to their html5rocks site, which provide further details and more in-depth tutorials of implemented specifications.

The current sections include:

This is certainly something to keep an eye on as, Chrome is setting the standard in terms of HTML5 support by desktop browser vendors.

Custom Search Engines in Chrome and Firefox

Recently I upgraded to a beautiful new iMac, on which I needed to configure my development environment and general workflow preferences. This required a few steps which I haven’t performed in quite some time and, upon doing so, I was reminded of how minor, yet useful many of these simple configurations actually are.

One such configuration involved defining Custom Search Engines in both Chrome and Firefox – a rather nice facility a colleague shared with me a while back. In case you haven’t used them before, Custom Search Engines allow for defining simple and complex search queries which can be easily invoked using a predefined keyword in the Address bar in Firefox or Omnibox in Chrome.

For instance, I use a Custom Search Engine with JIRA for quickly searching tickets, etc. Once set up, searching (by example of JIRA) is as simple as typing in my chosen keyword “t” (for ticket) and entering a ticket number, as can be seen below:
Custom Search Chrome
Custom Search Engine in Chrome

Likewise, in Firefox, typing my Custom Search Engine keyword for JIRA in the Address bar brings up the following prompt:
Custom Search Firefox
Custom Search Engine in Firefox

Defining a Custom Search Engine

Setting up your own Custom Search Engine is simple and straightforward. Doing so in Chrome can be accomplished as follows:

  1. Select the Wrench Icon.
  2. Under Preferences, select “Basics”.
  3. In the Search Section, click on the “Manage Search Engines…” button.
  4. In the “Other Search Engines” Section, add the name of your Search Engine, your search Keyword and the URL of the site you will be using, appending %s to the end in place of the Query.
  5. Once completed, enter the keyword into the Omnibox. You will see the the Name you choose for the Search Engine automatically added. Type a Query, hit Enter, and you are all set.

In Firefox creating a Custom Search Engine is accomplished by specifying a “keyword” when adding a bookmark and, appending the bookmarked URL with %s in place of the Query. This can be done as follows:

  1. From the Menu Bar, select “Bookmarks”.
  2. In the Menu Drop down, select “Show all Bookmarks”.
  3. In the Bookmark Library Dialog, select a folder (e.g. Bookmarks Toolbar).
  4. Click on the Gear Icon in the top left of the Dialog.
  5. From the Drop down, select “New Bookmark…”
  6. Enter the Name of your Bookmark/Custom Search Engine.
  7. In the Location field, enter the URL of the site you will be searching, replacing the query with %s (use existing Search Engines entries as a reference if needed).
  8. In the Keyword field, enter an arbitrary keyword of your choosing.
  9. Click “Add”
  10. Enter the keyword followed by your query in the Address Bar. You will see the Name you choose for the Search Engine automatically added in the History Dropdown. Hit Enter, and you are all set.

And thats basically all there is to it. Simple, quick and useful.

Multiple Form Factor Software Design

I have been giving a lot of thought lately about designing software in a Multi-Form Factor paradigm and felt I would share some initial thoughts on the subject. Keep in mind much of this is still quite new and subject to change; however, I have made an attempt to isolate what I feel will remain constant moving forward.

First, User Experience Design

My initial thoughts on the implications of what an ever growing Multi-Form Factor paradigm will have on the way we think about the design of software are primarily concerned with User Experience Design. While using CSS3 media queries to facilitate dynamic layouts will be needed for most Web Applications, I do not believe these types of solutions alone will allow for the kinds of compelling experiences users have come to expect, especially as they will likely compare Mobile Web Application experiences to their native counterparts. Sure some basic solutions will be needed, and for some simple websites they may suffice. However, in the context Web Applications, as well as just about every application developed specifically for a PC, too, I believe UX Design will need to leverage the unique opportunities presented by each particular form factor, be it a PC, smartphone, tablet or TV. Likewise, UX will need to account for the constraints of each form-factor as well. Architecturally, all of the above presents both opportunity and challenge.

To further illustrate this point, consider the fact that it is arguably quite rare that a UX Design intended for users of a PC will easily translate directly to a Mobile or Tablet User Experience. The interactions of a traditional physical keyboard and mouse do not always equate to those of soft keys, virtual keyboards and touch gesture interactions. Moreover, the navigation and transitions between different views and even certain concepts and metaphors are completely different. In simplest terms; it’s not “Apples to Apples”, as the expression goes.

With this in mind, as always, UX Design will need to remain at the forefront of Software Design.

Second, Architecture

Multi-Form Factor design obviously poses some new Architectural challenges considering the growing number of form factors which will need to be taken into account. The good news is, most existing, well designed software architectures may have been designed with this in mind to a certain degree. That is, the key factor in managing this complexity I believe will be code reuse; specifically, generalization and abstraction. A common theme amongst many of my posts, code reuse has many obvious benefits, and in the context of Multi-Form Factor concerns it will allow for different device specific applications to leverage general, well defined and well tested APIs. A good example being a well designed RESTful JSON service.

Code reuse will certainly be of tremendous value when considering the complexities encountered with Multi-Form Factor design. Such shared libraries, APIs and Services can be reused across applications which are designed for particular Form-Factors or extended to provide screen / device specific implementations.

Some Concluding Thoughts

In short, I believe both users and developers alike will be best served by providing unique User Experiences for specific Form Factors as opposed to attempting to adapt the same application across Multiple Form Factors. One of the easiest ways of managing this complexity will inevitably be code reuse.

I also believe the main point of focus should be on the medium and small form factors; i.e. Tablets and Smart phones. Not only for the more common reasons but, also because I believe PCs and Laptops will eventually be used almost exclusively for developing the applications which run on the other form factors. In fact, I can say this from my own experiences already.

While there is still much to learn in the area of Multi-Form Factor Design, I feel the ideas I’ve expressed here will remain relevant. Over the course of the coming months I plan to dedicate much of my time towards further exploration of this topic and will certainly continue to share my findings.

AJAX Desktop Beta

I used to build lots of .swf’s embedded in html pages and set the html page as my desktop as oppossed to just having an image set as my desktop. This was cool because the swf would read from an xml file and add links that I can access directly from my desktop. I also had various effects and what not as well as news aggregators, clocks and an mp3 player. The only problem that I couldn’t seem to solve is that when I would try to make a selection on my desktop focus was on the .swf and not the desktop. So this was a problem.

My solution was to do the same exact thing but in AJAX rather than flash this way focus would remain on the desktop. Below is a link to the working sample as well as a link to the source files for you to use as you wish. Simply add all of your favorite images in the images folder and then modify the ajax-desktop.js file and add your images as indexes of the ‘imagesArray’. Everytime you boot up you will have a different image load randomly as your desktop. You can add links to your executables allowing you to rid yourself of desktop icons as well as links to your favorite sites.

Sample:
ajax-desktop.html

Download Source code:
ajax-desktop.zip