Costly communion : ecumenical initiative and sacramental strife in the Anglican Communion / edited by Mark D. Chapman, Jeremy Bonner
Fundamentalism or tradition : Christianity after secularism / Aristotle Papanikolaou and George E. Demacopoulo, editors
The garb of being : embodiment and the pursuit of holiness in late ancient Christianity / Georgia Frank, Susan R Holman, and Andrew S. Jacobs, editors
The governor and the king : irony, hidden transcripts, and negotiating empire in the Fourth Gospel / Arthur M. Wright Jr. ; foreword by Frances Taylor Gench
Handbook of global contemporary Christianity : movements, institutions, and allegiance / edited by Stephen Hunt
Worship and social engagement in urban Aboriginal-led Australian Pentecostal congregations : (re)imagining identity in the spirit / by Tanya Riches
Thomas Thornton Reed, Anglican Archbishop of Adelaide : essays and reminiscences / compiled by Airlie Black
Sacraments, ceremonies and the Stuart divines : sacramental theology and liturgy in England and Scotland 1603-1662 / Bryan D. Spinks
Infections of the Central Nervous System: Pathology and Genetics
Highly commended at the British Medical Association (BMA) Awards 2019, this new volume from the International Society of Neuropathology series addresses infections of the nervous system, written by expert editors. An expansive and inclusive contents list including rare disorders presented in easily referable chapters, containing; definitions, microbiological characteristics, epidemiology, clinical features, lab tests, pathology, genetics and treatment Read More... |
The Chemical Biology of Plant Biostimulants
Introduces readers to the chemical biology of plant biostimulants This book brings together different aspects of biostimulants, providing an overview of the variety of materials exploited as biostimulants, their biological activity, and agricultural applications. As different groups of biostimulants display different bioactivity and specificity, advances in biostimulant research is illustrated by different examples of biostimulants, such as humic substance Read More... |
Handbook of In Vivo Chemistry in Mice: From Lab to Living System
Provides timely, comprehensive coverage of in vivo chemical reactions within live animals This handbook summarizes the interdisciplinary expertise of both chemists and biologists performing in vivo chemical reactions within live animals. By comparing and contrasting currently available chemical and biological techniques, it serves not just as a collection of the pioneering work done in animal-based studies, but also as a technical guide to help readers Read More... |
Superior performance of surface-treated NaX@Pebax-1657 membranes for O2/N2 separation
DOI: 10.1039/D0RA02255A, Paper
In this study, the performances of mixed matrix composite membranes (MMCMs) containing surface-treated NaX nanocrystals (ST-NaX-NCs) were experimentally and theoretically investigated for O2/N2 separation.
The content of this RSS Feed (c) The Royal Society of Chemistry
An ionic diode based on a spontaneously formed polypyrrole-modified graphene oxide membrane
DOI: 10.1039/D0RA01145B, Paper
We described an ionic diode based on polypyrrole-modified graphene oxide membrane, which was prepared by a spontaneous oxidation polymerization of pyrrole monomers.
The content of this RSS Feed (c) The Royal Society of Chemistry
Laminin-modified gellan gum hydrogels loaded with the nerve growth factor to enhance the proliferation and differentiation of neuronal stem cells
DOI: 10.1039/D0RA01723J, Paper
Laminin-modified thiolated gellan gum and loaded with the nerve growth factor in facilitateding neuronal stem cell proliferation and differentiation.
The content of this RSS Feed (c) The Royal Society of Chemistry
MOF-derived (MoS2, γ-Fe2O3)/graphene Z-scheme photocatalysts with excellent activity for oxygen evolution under visible light irradiation
DOI: 10.1039/D0RA02083D, Paper
The heterojunction between MoS2 and γ-Fe2O3 was constructed via linking by in situ formed graphene, which resulted in a good photocatalyst for the oxygen evolution reaction, showing O2 evolution activity of 4400 μmol g−1 h−1.
The content of this RSS Feed (c) The Royal Society of Chemistry
A three-dimensional electrode bioelectrochemical system for the advanced oxidation of p-nitrophenol in an aqueous solution
DOI: 10.1039/C9RA08538F, Paper
PNP absorbed in and surrounded by GPEs has kinetic favorability in the degradation process by a three-dimensional electrode MFC-Fenton system.
The content of this RSS Feed (c) The Royal Society of Chemistry
Surface modification of a PES membrane by corona air plasma-assisted grafting of HB-PEG for separation of oil-in-water emulsions
DOI: 10.1039/D0RA02032J, Paper
The main goal of this study is to modify a polyethersulfone (PES) membrane by grafting with hyperbranched polyethylene glycol (HB-PEG) using corona air plasma to intensify the anti-fouling properties of the prepared membrane.
The content of this RSS Feed (c) The Royal Society of Chemistry
Retraction: Effect of temperature and large guest molecules on the C–H symmetric stretching vibrational frequencies of methane in structure H and I clathrate hydrates
DOI: 10.1039/D0RA90048F, Retraction
The content of this RSS Feed (c) The Royal Society of Chemistry
Room-temperature synthesis and CO2-gas sensitivity of bismuth oxide nanosensors
DOI: 10.1039/D0RA00801J, Paper
Room-temperature (27 °C) synthesis and carbon dioxide (CO2)-gas-sensing applications of bismuth oxide (Bi2O3) nanosensors obtained via a direct and superfast chemical-bath-deposition method (CBD) with different surface areas and structures.
The content of this RSS Feed (c) The Royal Society of Chemistry
A superhydrophilic bilayer structure of a nylon 6 nanofiber/cellulose membrane and its characterization as potential water filtration media
DOI: 10.1039/D0RA01077D, Paper
The SEM image of (a) cellulose membrane and (b) the bilayer structure of a nylon 6 nanofibrous membrane on a cellulose membrane as water filter media.
The content of this RSS Feed (c) The Royal Society of Chemistry
Structural, optical and photocatalytic properties of erbium (Er3+) and yttrium (Y3+) doped TiO2 thin films with remarkable self-cleaning super-hydrophilic properties
DOI: 10.1039/D0RA02242J, Paper
The self-cleaning and super hydrophilic properties of pristine TiO2 and of TiO2 doped with Er3+ or Y3+ transparent thin films deposited onto glass substrates were investigated.
The content of this RSS Feed (c) The Royal Society of Chemistry
In vivo and in vitro evaluation of dihydroartemisinin prodrug nanocomplexes as a nano-drug delivery system: characterization, pharmacokinetics and pharmacodynamics
DOI: 10.1039/D0RA02150D, Paper
To develop new, more effective and lower toxicity antitumor dihydroartemisinin (DHA) nanocomplexes, a DHA prodrug synthesized in this study was used to prepare DHA prodrug self-assembled nanocomplexes (DHANPs) by molecular self-assembly technology.
The content of this RSS Feed (c) The Royal Society of Chemistry
Correction: Insects (Thrips hawaiiensis (Morgan)) change the stereochemical configuration of 1-phenylethanol emitted from tea (Camellia sinensis) flowers
DOI: 10.1039/D0RA90047H, Correction
The content of this RSS Feed (c) The Royal Society of Chemistry
49.25% efficient cyan emissive sulfur dots via a microwave-assisted route
DOI: 10.1039/D0RA02778B, Paper
The cyan emissive sulfur dots with a record high PL QY of 49.25% were successfully synthesized via a microwave-assisted route.
The content of this RSS Feed (c) The Royal Society of Chemistry
Simple organocatalyst component system for asymmetric hetero Diels–Alder reaction of isatins with enones
DOI: 10.1039/D0RA03006F, Paper
A simple two catalysts component system of β-amino alcohols (catalyst) and amino acids (co-catalyst) works as an efficient organocatalysts in hetero Diels–Alder reaction of isatins with enones to afford chiral spirooxindole-tetrahydropyranones.
The content of this RSS Feed (c) The Royal Society of Chemistry
Cost-effective smart microfluidic device with immobilized silver nanoparticles and embedded UV-light sources for synergistic water disinfection effects
DOI: 10.1039/D0RA00076K, Paper
A novel microfluidic-device for water disinfection via diverse physiochemical effects has been demonstrated.
The content of this RSS Feed (c) The Royal Society of Chemistry
Wrist flexible heart pulse sensor integrated with a soft pump and a pneumatic balloon membrane
DOI: 10.1039/D0RA02316G, Paper
Wearable and flexible heart pulse sensor is proposed to monitor the detailed pulse signal from a wrist stably and reliably by integrating a tactile pressure sensor and a soft pneumatic balloon operated by a soft pump.
The content of this RSS Feed (c) The Royal Society of Chemistry
Exploring a lead-free organic–inorganic semiconducting hybrid with above-room-temperature dielectric phase transition
DOI: 10.1039/C9RA09289G, Paper
Recently, organic–inorganic hybrid lead halide perovskites have attracted great attention for optoelectronic applications, such as light-emitting diodes, photovoltaics and optoelectronics.
The content of this RSS Feed (c) The Royal Society of Chemistry
Detection of L-band electron paramagnetic resonance in the DPPH molecule using impedance measurements
DOI: 10.1039/D0RA03285A, Paper
(a) Schematic diagram of our experimental set up. (b) Resistance and reactance of the DPPH molecule for 2 GHz current in the strip coil.
The content of this RSS Feed (c) The Royal Society of Chemistry
Fabrication of a magnetic ternary ZnFe2O4/TiO2/RGO Z-scheme system with efficient photocatalytic activity and easy recyclability
DOI: 10.1039/D0RA01880E, Paper
A magnetic separable Z-scheme composite based on ZnFe2O4, TiO2 nanosheets and RGO exhibits efficient photocatalytic degradation of p-NP.
The content of this RSS Feed (c) The Royal Society of Chemistry
Deposition of an ultra-thin polyaniline coating on a TiO2 surface by vapor phase polymerization for electrochemical glucose sensing and photocatalytic degradation
DOI: 10.1039/D0RA01571G, Paper
Here, we have synthesized an ultra-thin coating of polyaniline on a TiO2 nanoparticle surface (PANI–TiO2) using a simple vapor phase polymerization method.
The content of this RSS Feed (c) The Royal Society of Chemistry
Borohydride catalyzed redistribution reaction of hydrosilane and chlorosilane: a potential system for facile preparation of hydrochlorosilanes
DOI: 10.1039/D0RA03536J, Paper
A borohydride catalyzed Si–H/Si–Cl redistribution system was established to prepare hydrochlorosilanes facilely and efficiently.
The content of this RSS Feed (c) The Royal Society of Chemistry
Synthesis and gas permeation properties of thermally rearranged poly(ether-benzoxazole)s with low rearrangement temperatures
DOI: 10.1039/D0RA00145G, Paper
A series of poly(ether-benzoxazole)(PEBO) for gas separation were prepared from 9,9-bis[4-(4-amino-3-hydroxylphenoxy)phenyl]fluorene based hydroxyl-containing poly(ether-imide)s (HPEIs) with low rearrangement temperatures.
The content of this RSS Feed (c) The Royal Society of Chemistry
A dopamine electrochemical sensor based on a platinum–silver graphene nanocomposite modified electrode
DOI: 10.1039/C9RA11056A, Paper
A platinum–silver graphene nanocomposite was synthesized and characterized. A nanocomposite modified electrode was fabricated in order to investigate the electrochemical detection of dopamine.
The content of this RSS Feed (c) The Royal Society of Chemistry
Cobalt–carbon/silica nanocomposites prepared by pyrolysis of a cobalt 2,2'-bipyridine terephthalate complex for remediation of cationic dyes
DOI: 10.1039/D0RA02752A, Paper
A cobalt–carbon@silica nanocomposite was synthesized from a cobalt 2,2'-bipyridine terephthalate complex and its adsorption behavior towards crystal violet dye was tested using batch and column techniques.
The content of this RSS Feed (c) The Royal Society of Chemistry
A facile method for preparing Yb3+-doped perovskite nanocrystals with ultra-stable near-infrared light emission
DOI: 10.1039/D0RA01897J, Paper
A facile method for fabricating CsPbBr3:Yb3+@SiO2 NCs which guarantees high PLQY and excellent stability at the same time.
The content of this RSS Feed (c) The Royal Society of Chemistry
Effect of temperature and large guest molecules on the C–H symmetric stretching vibrational frequencies of methane in structure H and I clathrate hydrates
DOI: 10.1039/D0RA02748K, Paper
Temperature effect on C–H symmetric stretching frequencies of CH4 in water cages of sI and sH clathrate hydrates were clarified.
The content of this RSS Feed (c) The Royal Society of Chemistry
Mechanochemical approach to synthesize citric acid-soluble fertilizer of dittmarite (NH4MgPO4·H2O) from talc/NH4H2PO4 mixture
DOI: 10.1039/D0RA00387E, Paper
Dittmarite synthesis by a mechanochemical route for application as a citric acid-soluble fertilizer.
The content of this RSS Feed (c) The Royal Society of Chemistry
Enhancing the performance of LARP-synthesized CsPbBr3 nanocrystal LEDs by employing a dual hole injection layer
DOI: 10.1039/D0RA02622K, Paper
The current and power efficiencies of CsPbBr3 NC LEDs are improved 1.5 and 1.8 times by employing a dual HAT-CN/MoO3 hole injection layer.
The content of this RSS Feed (c) The Royal Society of Chemistry
A novel series of phenolic temozolomide (TMZ) esters with 4 to 5-fold increased potency, compared to TMZ, against glioma cells irrespective of MGMT expression
DOI: 10.1039/D0RA02686G, Paper
The standard of care treatment for patients diagnosed with glioblastoma multiforme (GBM) is temozolomide (TMZ).
The content of this RSS Feed (c) The Royal Society of Chemistry
Electrochemical reduction of CO2 to ethylene on Cu/CuxO-GO composites in aqueous solution
DOI: 10.1039/D0RA02754E, Paper
Herein, we present fabrication of graphene oxide supported Cu/CuxO nano-electrodeposits which efficiently and selectively can electroreduce CO2 into ethylene with a faradaic efficiency of 34% and conversion rate of 194 mmol g−1 h−1 at −0.985 V vs. RHE.
The content of this RSS Feed (c) The Royal Society of Chemistry
Facile synthesis of a direct Z-scheme BiOCl–phosphotungstic acid heterojunction for the improved photodegradation of tetracycline
DOI: 10.1039/D0RA02396E, Paper
A one-step hydrothermal approach for synthesizing BiOCl–phosphotungstic acid (BiOCl–HPW) heterojunctions is proposed. The prepared BiOCl–HPW heterojunction exhibited good stability and photocatalytic activity.
The content of this RSS Feed (c) The Royal Society of Chemistry
Anatomy of an HTML5 WordPress theme
This site has been written in HTML5 and used to use WordPress to manage the content. I’ll explain why I used HTML5, describe the structure of the theme templates, and show some of the ways I tried to tame WordPress’s tendency to add mess to the source code.
As this is my personal site I wanted to experiment with using HTML5, CSS3, and WAI-ARIA. All these documents are currently working drafts and subject to change. However, the web documents and applications of the future are going to be written in HTML5 and I wanted to see the benefits of using it to markup static documents. Using CSS 2.1, let alone the CSS3 selectors and properties that some browser vendors have implemented, has many advantages for controlling the presentation of semantically coded documents. For this reason I am not going to avoid using basic CSS 2.1 selectors just to faithfully reproducing this site’s design in IE6. However, I have tried to accommodate IE 7 and IE 8 users by using an HTML5 enabling script so that the new HTML5 elements can be styled in those browsers if users have Javascript enabled.
HTML5 templates
I started with a static prototype of this site developed on my local server. WordPress makes it very easy to create your own templates and, therefore, it is no problem to use HTML5. This theme only has 3 main templates: index, single, and archive. There are of course templates for 404s, attachments, comments, etc., but I won’t discuss them as they are all based on the 3 main templates. All the templates include ARIA roles as an accessibility aide.
The single.php
template has this rough structure:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="default.css">
</head>
<body>
<header role="banner"></header>
<nav role="navigation"></nav>
<article role="main">
<header>
<time datetime="YYYY-MM-DD"></time>
<h1></h1>
</header>
<footer></footer>
</article>
<nav></nav>
<aside role="complementary"></aside>
<footer role="contentinfo">
<small></small>
</footer>
</body>
</html>
The first line of the document is the HTML5 DOCTYPE. The new <article>
element contains the content of each post. The same structure is used for the
index.php
template except that there are several articles displayed on each
page and the ARIA role value of main
is not used. In contrast, the
archive.php
template houses all the article excerpts in a <section>
element
with the ARIA
role of main
because the list of archived posts is itself the
main content of the document.
A clean theme
WordPress tends to add classes, elements, and other bits of code in certain
places. I haven’t used any of the WordPress functions that add class names to
the body and to elements wrapping a post and also wanted to avoid cluttering
the source code with any other unnecessary markup. This required a bit of
fiddling around with the theme’s functions.php
file. I’m not a PHP developer
so this might not be pretty!
Removing actions from wp_head()
WordPress has a hook called wp_head
that sits in the header.php
of most
themes. To avoid it inserting unwanted code into the <head>
of the document I
used the remove_action
function to disable the functions that were
responsible. The following code was added to the functions.php
file of my
theme:
// Remove links to the extra feeds (e.g. category feeds)
remove_action( 'wp_head', 'feed_links_extra', 3 );
// Remove links to the general feeds (e.g. posts and comments)
remove_action( 'wp_head', 'feed_links', 2 );
// Remove link to the RSD service endpoint, EditURI link
remove_action( 'wp_head', 'rsd_link' );
// Remove link to the Windows Live Writer manifest file
remove_action( 'wp_head', 'wlwmanifest_link' );
// Remove index link
remove_action( 'wp_head', 'index_rel_link' );
// Remove prev link
remove_action( 'wp_head', 'parent_post_rel_link', 10, 0 );
// Remove start link
remove_action( 'wp_head', 'start_post_rel_link', 10, 0 );
// Display relational links for adjacent posts
remove_action( 'wp_head', 'adjacent_posts_rel_link', 10, 0 );
// Remove XHTML generator showing WP version
remove_action( 'wp_head', 'wp_generator' );
Source: WPEngineer.com: Cleanup WordPress Header
Removing an empty <span>
If you want to create excerpts you can either write them into the excerpt box
or use the <--more-->
quicktag in the WordPress editor. I just wanted the
first paragraph of my posts to be used as the excerpt and so using the
in-editor tag was the most practical approach I was aware of. However, when you
do this WordPress will insert an empty <span>
in the post’s content. This
element has an id
so that the area following the excerpt can be targeted by
“more” or “continue reading” links. I removed both the empty <span>
and the
jump link by adding the following code to the functions.php
file of the
theme:
// removes empty span
function remove_empty_read_more_span($content) {
return eregi_replace("(<p><span id="more-[0-9]{1,}"></span></p>)", "", $content);
}
add_filter('the_content', 'remove_empty_read_more_span');
Source: Ganda Manurung: Remove Empty Span Tag On WordPress
// removes url hash to avoid the jump link
function remove_more_jump_link($link) {
$offset = strpos($link, '#more-');
if ($offset) {
$end = strpos($link, '"',$offset);
}
if ($end) {
$link = substr_replace($link, '', $offset, $end-$offset);
}
return $link;
}
add_filter('the_content_more_link', 'remove_more_jump_link');
Source: WordPress Codex: Customizing the Read More
Displaying images in the excerpt
For posts that display nothing but a photograph (yes, they will be shit but I’m
hoping it gets me using my camera a bit more often) I wanted the image to show
up in the archives. Equally, if the first paragraph of a post contained a link
I wanted that to be preserved. The default the_excerpt()
template tag doesn’t
allow for this so it needed some modifying. I added a new function, which is
just a modified version of the core excerpt function, to the functions.php
file and then made sure that the template tag executed this function rather
than the one contained in the core WordPress files.
function improved_trim_excerpt($text) {
if ( '' == $text ) {
$text = get_the_content('');
$text = strip_shortcodes( $text );
$text = apply_filters('the_content', $text);
$text = str_replace(']]>', ']]&gt;', $text);
$text = strip_tags($text, '<p><img><a>');
$excerpt_length = apply_filters('excerpt_length', 55);
$words = explode(' ', $text, $excerpt_length + 1);
if (count($words) > $excerpt_length) {
array_pop($words);
array_push($words, '[...]');
$text = implode(' ', $words);
$text = force_balance_tags($text);
}
}
return $text;
}
remove_filter('get_the_excerpt', 'wp_trim_excerpt');
add_filter('get_the_excerpt', 'improved_trim_excerpt');
Source: Aaron Russell: Improving WordPress’ the_excerpt() template tag
Conditional next/prev links
I prefer not to have empty elements in the markup and so I needed a way to
conditionally insert the “Older entries”, “Newer Entries”, etc., links into
templates. The solution I’m using here, which isn’t perfect, is to add this to
functions.php
:
function show_posts_nav() {
global $wp_query;
return ($wp_query->max_num_pages > 1);
}
Source: Eric Martin: Conditional navigation links in WordPress
And then to wrap the navigation markup in the templates with the following:
<?php if (show_posts_nav()) : ?>
<nav>
<ul>
<li><?php next_posts_link('« Older Entries') ?></li>
<li><?php previous_posts_link('Newer Entries »') ?></li>
</ul>
</nav>
<?php endif; ?>
Summary
It’s fairly easy to create a simple site with HTML5 and to use WordPress to
deliver it. At the moment there are issues with Internet Explorer because you
cannot style HTML5 elements unless you use Javascript. However, HTML5 redefines
the meaning of certain elements (such as <dl>
, which has become a more
versatile “description list”) and allows block elements to be wrapped in a
link. Therefore, there is still benefit in using the HTML5 DOCTYPE even if you
do not make use of the new elements.
Further reading
- HTML5 working draft
- HTML5 differences from HTML4
- Accessible Rich Internet Applications (WAI-ARIA) 1.0
Thoughts on some new HTML5 elements
In the last few months there has been increased discussion about some of the new elements that have been introduced in the HTML5 draft specification. This entry is primarily a counter argument to some of the comments that I disagree with.
The most recent and high-profile comments in regard to parts of the HTML5 specification come from The HTML5 Super Friends in an article entitled Guide to HTML5 Hiccups. It lays out their concerns with the HTML5 draft specification as it stood at the time of its writing and I am largely going to focus on the issues they have discussed.
The article
and section
elements
The first argument that I disagree with is that the article
and section
elements are redundant and, therefore, that the article
element should be
dropped.
article
andsection
are identical except thatarticle
allows apubdate
attribute. We would suggest thatarticle
be dropped andsection
be adapted to allow an optionalpubdate
attribute or, even better, more explicit metadata.
The article
and section
elements are not identical according the to HTML5
draft specification. Here is what it says about the section
element as of
13 September 2009:
The
section
element represents a generic document or application section. A section, in this context, is a thematic grouping of content, typically with a heading, possibly with a footer.
Now contrast that with what it says about the the article
element:
The
article
element represents a section of a page that consists of a composition that forms an independent part of a document, page, application, or site.
An article
element is “independent” in the sense that its contents could
stand alone, for example in syndication, or as a interchangeable component on a
user-configurable portal page.
That is a clear distinction that resists the reading of article
and section
being “identical”. The article
element has a specific purpose: to mark parts
of a document that form an independent composition that may be appropriate for
syndication. It is a special kind of sectioning element that performs an
essential role that is lacking in the semantics of the generic section
element. This generic element serves only to thematically group content. That
grouping may occur at the document level, within an independent article
, or
within a footer
.
The article
element has unique semantics and practical use. There is a
fundamental conceptual difference between stand-alone compositions and sections
of compositions, documents, or pages and this difference should be recognised
and catered for in the specification. Websites regularly employ microformats
and you don’t have to look far to see independent compositions currently marked
up with class="hentry"
or find links to individual blog comments and twitter
updates. There is clearly a need for an easy way to define independent
compositions and that is met with the introduction of the article
element in
HTML5.
What may be needed is a stronger clarification and definition of the article
element to minimise the potential for this distinction to be overlooked and to
highlight the differences from a generic document section.
The hgroup
element
The hgroup
element is a relatively recent addition to the draft
specification. It is defined as serving a fairly specific purpose:
The
hgroup
element represents the heading of a section. The element is used to group a set ofh1
–h6
elements when the heading has multiple levels, such as subheadings, alternative titles, or taglines.
The element works to associate headings together so that the highest ranked
heading descendant (if present) of the hgroup
element is used as its text in
document outlines and summary. Other heading descendants are treated as
subheadings and are left out of outlines.
The HTML5 Super Friends have this to say about the hgroup
element:
We don’t see the added value of this element and would instead add a boolean attribute to the heading element which allows content authors to specify if that particular heading should be included in the outline.
Bruce Lawson has similar concerns and proposes another alternative – removing the need for a wrapping element and defining a new element specifically for marking up subtitles:
I agree that
hgroup
is clumsy and likely to be misused. Rather than wrap anh1
and itsh2
subtitle inhgroup
to keep the subtitle out of the outlining algorithm, I would prefer to use<header> <h1>My blog</h1> <subtitle>My wit and wisdom</subtitle> </header>
as I think that;s easier to understand than a heading-that’s-not-a-heading, and it removes a wrapping element.
I disagree with these criticisms of the hgroup
element and consider the
proposed alternatives to be more problematic, less intuitive, less flexible,
and further removed from the way in which authors currently markup subheadings.
The way that many authors are currently marking up subheadings is by using headings of various ranks and in various orders depending on whether the subheading or qualifying heading needs to appear above or below the main page heading. A subheading is still, conceptually, a heading of sorts and it cannot be accurately marked up with a paragraph or any other currently available element.
Allowing the addition of a boolean attribute to heading elements has several problems.
A boolean attribute may be less intuitive for authors than the
hgroup
element. Thehgroup
element relies upon and produces an association between all the headings it contains. Since headings and subheadings occur together and derive their meaning from each other, it is semantic to wrap these headings in an element. We know that the highest ranked heading contains the string to be used in the outline and that the other headings serve as ranked subheadings to this primary heading. A boolean attribute is only associated with the element that it is a part of. We can create no association between the element and adjacent elements. This is related to the next issue.The
hgroup
itself acts as heading content while a boolean attribute would act only to remove headings from the outline. Thehgroup
element only removes the descendant headings that are those not of the highest rank. The boolean attribute shifts the burden onto the author to decide which headings should be marked for removal from the outline, rather than providing an element to wrap a collection of headings without authors having to be concerned with (or aware of) issues of outlining.
What about Bruce Lawson’s idea for a subtitle
element? I believe that,
irrespective of the what this element were actually called, it suffers from
similar problems to the idea of using a boolean attribute. There is nothing to
prevent the use of a subtitle
element away from a heading, it creates no
association with other elements, and it does not allow for ranking of
subheadings.
One of my key points in relation to criticism of the hgroup
element is that
subheadings draw their meaning from context. A subheading (as opposed to a
section heading) is only a sub-heading if it is associated with a higher
ranking heading. Remove the higher ranking heading and what was once a
subheading is likely to be understood as a heading.
The strength of the hgroup
element over the two alternative suggestions I
have referenced is that it is the only proposal that defines a subheading as
contextual. I think that it is the most intuitive proposal (although perhaps
none of them are particularly inuitive) – the name of the element is
self-descriptive and encapsulates the contextual relationship and adjacent
positioning of its child elements — and matches most closely with the way
that subheadings are currently marked up on many websites.
The aside
element
The HTML5 Super Friends are of the opinion that the aside
element is not
worth including in the specification:
The use cases for aside are too limited to warrant its inclusion in the specification. We were also concerned about potentially duplicating content within an aside.
However, the specification itself provides some fairly compelling uses for the element:
The element can be used for typographical effects like pull quotes or sidebars, for advertising, for groups of
nav
elements, and for other content that is considered separate from the main content of the page.
Authors might use the aside
element for their blogrolls, for marking up
adverts ranging from google ads on blogs to large banners on enterprise
websites, for expanding on themes within an article or providing an extended
definition of a term, for pull quotes, and anything else “tangentially
related to the content around the aside element, and which could be considered
separate from that content”.
Most of these uses would not involve duplication of content. Using the aside
element for pull quotes would produce some instances of content duplication.
However, this is not really a problem for users who are used to content being
duplicated in this way in newspapers and magazines. It would not take much for
search engines to adapt to deal with short amounts of duplicate content
contained within an aside
either. While I appreciate the point about
duplicate content I’m not yet convinced that it is actually problematic.
The legend
element
The current specification defines the legend
element as providing an
explanatory caption for the contents of its parent element. The parent element
may be a fieldset
, figure
or details
element. However, Remy
Sharp‘s article entitled legend not such a legend
anymore shows why it
is not practical to use legend
for the new elements details
and figure
–
because it is not backwards compatible with current browsers and effectively
unusable outside of a fieldset
because of the inability to style the element.
In this case, forging a new element is most appropriate rather than trying to
use an element like label
which will only create confusion with little
advantage.
Summary
I have discussed my reasons for disagreeing with certain feedback on the HTML5
draft specification. I have yet to be convinced that the article
, hgroup
,
or aside
elements should be dropped from the specification because it seems
to me that they have necessary uses and advantages over alternatives.
New HTML5 elements: summary & figcaption
Over the weekend two new HTML5 elements – summary
and figcaption
– were
added to the draft specification. The introduction of summary
and
figcaption
marks the acceptance that new elements are needed to act as
captions or legends for the details
and figure
elements. The addition of
the figcaption
element finally begins to clear up the difficulty in
marking-up figure
element captions and looks to cement the place of the
figure
element in the HTML5 specification. The summary
element does much
the same for the details
element but the very nature of the details
element
itself means that its future is not yet clear.
The figcaption
element
This new element acts as the optional caption or legend for any content
contained within its parent figure
element.
If there is no figcaption
element within a figure
element then there is no
caption for the rest of its content. If there is a figcaption
element then it
must be the first or last child of the figure
element and only the first
figcaption
element (should there be more than one child figcaption
of the
parent figure
element) represents a caption.
The figure
element is used to mark up any self-contained content that may be
referenced from the main flow of a document but could also be removed from the
primary content (for example, to an appendix) without affecting its flow. This
makes it suitable for various types of content ranging from graphs and data
tables to photographs and code blocks.
<p><a href="#fig-ftse">Figure 1</a> shows the extent of the collapse in the markets and how recovery has been slow.</p>
<figure id="fig-ftse">
<figcaption>Figure 1. The value of the FTSE 100 Index from 1999–2009.</figcaption>
<img src="ftse-100-index-graph.jpg" alt="The index hit a record high at the end of 1999 and experienced two significant drops in the following last decade.">
</figure>
<p>This latest financial crisis hasn't stopped Alex from writing music and his latest track is actually worth listening to.</p>
<figure>
<audio src="what-am-i-doing.mp3" controls></audio>
<figcaption><cite>What am I doing?</cite> by Alex Brown</figcaption>
</figure>
The creation of the figcaption
element is an important step forward for the
HTML5 draft specification as it finally provides a reliable means to markup the
caption for content that is best marked up as a figure
. Previous attempts to
use the legend
element, the caption
element, and the dt
and dd
elements
had failed due to a lack of backwards compatibility when it came to styling
these elements with CSS.
The summary
element
This new element represents a summary, caption, or legend for any content
contained within its parent details
element.
The summary
element must be the first child of a details
element and if
there is no summary
element present then the user agent should provide its
own. The reason for this is because the details
element has a specific
function – to markup additional information and allow the user to toggle the
visibility of the additional information. Although it is not specified in the
specification, it is expected that the summary
element will act as the
control that toggles the open-closed status of the contents of the parent
details
element.
<details>
<summary>Technical details.</summary>
<dl>
<dt>Bit rate:</dt> <dd>190KB/s</dd>
<dt>Filename:</dt> <dd>drum-and-bass-mix.mp3</dd>
<dt>Duration:</dt> <dd>01:02:34</dd>
<dt>File size:</dt> <dd>78.9MB</dd>
</dl>
</details>
The introduction of the summary
element seems to secure the future of the
details
element and the new behaviour that it affords, for now. When user
agents begin to add support for the details
element you won’t need
JavaScript, or even CSS, to have expanding or collapsing sections in an HTML
document.
The future of the details
element
There will continue to be some debate over the inclusion of behaviour in an
HTML specification especially given the widespread use of JavaScript to provide
the expand-collapse functionality that details
describes.
The details
element writes some quite significant behaviour into an HTML
document and I can see it being abused to provide generic expand-collapse
functionality throughout a document. It is also not entirely clear what purpose
the details
element actually serves other than being an attempt to bypass the
need for JavaScript or CSS to expand or collapse sections of a document.
There has been a general softening of the rough distinction between content, presentation, and behaviour. JavaScript libraries are being used to patch holes in browser CSS and HTML5 support, the CSS3 modules introduce plenty of behaviour that was previously only possibly with JavaScript, and the HTML5 specification is also introducing functionality and behaviour that previously required the use of JavaScript.
The future survival of the details
element, and the behaviour associated with
it, may well depend on browser implementations and author applications over the
coming months.
Using HTML5 elements in WordPress post content
Here are two ways to include HTML5 elements in your WordPress post content
without WordPress’ wpautop
function wrapping them in p
tags or littering
your code with line breaks.
HTML5 has several new elements that you may want to use in your post content to markup document sections, headers, footers, pullquotes, figures, or groups of headings. One way to safely include these elements in your posts is simple; the other way is a bit more complicated. Both ways rely on hand-coding the HTML5 markup in the WordPress editor’s HTML view.
If you are adding HTML5 elements to your post content then you should use an HTML5 doctype.
Disable wpautop
for your theme
This is the simple way. Disable the wpautop
function so that WordPress makes
no attempt to correct your markup and leaves you to hand-code every line of
your posts. If you want total control over every line of your HTML then this is
the option for you.
To disable wpautop
entirely add these lines to your theme’s
functions.php
:
remove_filter('the_excerpt', 'wpautop');
remove_filter('the_content', 'wpautop');
However, wpautop
is generally quite useful if most of your posts are simple
text content and you only occasionally want to include HTML5 elements.
Therefore, modifying wpautop
to recognise HTML5 elements might be more
practical.
Modify wpautop
to recognise HTML5 elements
WordPress’ wpautop
is part of the core functions and can be found in this
file within your WordPress installation: wp-includes/formatting.php
. It
controls how and where paragraphs and line breaks are inserted in excerpts and
post content.
In order to create a modified version of WordPress’ core wpautop
function I
started off by duplicating it in my theme’s functions.php
file.
What I’ve experimented with is disabling wpautop
and adding a modified copy
of it – which includes HTML5 elements in its arrayss – to my theme’s
functions.php
file.
Add the following to your theme’s functions.php
file and you’ll be able to
use section
, article
, aside
, header
, footer
, hgroup
, figure
,
details
, figcaption
, and summary
in your post content. (Probably best to
try this in a testing environment first!)
/* -----------------------------
MODIFIED WPAUTOP - Allow HTML5 block elements in wordpress posts
----------------------------- */
function html5autop($pee, $br = 1) {
if ( trim($pee) === '' )
return '';
$pee = $pee . "
"; // just to make things a little easier, pad the end
$pee = preg_replace('|<br />s*<br />|', "
", $pee);
// Space things out a little
// *insertion* of section|article|aside|header|footer|hgroup|figure|details|figcaption|summary
$allblocks = '(?:table|thead|tfoot|caption|col|colgroup|tbody|tr|td|th|div|dl|dd|dt|ul|ol|li|pre|select|form|map|area|blockquote|address|math|style|input|p|h[1-6]|hr|fieldset|legend|section|article|aside|header|footer|hgroup|figure|details|figcaption|summary)';
$pee = preg_replace('!(<' . $allblocks . '[^>]*>)!', "
$1", $pee);
$pee = preg_replace('!(</' . $allblocks . '>)!', "$1
", $pee);
$pee = str_replace(array("
", "
"), "
", $pee); // cross-platform newlines
if ( strpos($pee, '<object') !== false ) {
$pee = preg_replace('|s*<param([^>]*)>s*|', "<param$1>", $pee); // no pee inside object/embed
$pee = preg_replace('|s*</embed>s*|', '</embed>', $pee);
}
$pee = preg_replace("/
+/", "
", $pee); // take care of duplicates
// make paragraphs, including one at the end
$pees = preg_split('/
s*
/', $pee, -1, PREG_SPLIT_NO_EMPTY);
$pee = '';
foreach ( $pees as $tinkle )
$pee .= '<p>' . trim($tinkle, "
") . "</p>
";
$pee = preg_replace('|<p>s*</p>|', '', $pee); // under certain strange conditions it could create a P of entirely whitespace
// *insertion* of section|article|aside
$pee = preg_replace('!<p>([^<]+)</(div|address|form|section|article|aside)>!', "<p>$1</p></$2>", $pee);
$pee = preg_replace('!<p>s*(</?' . $allblocks . '[^>]*>)s*</p>!', "$1", $pee); // don't pee all over a tag
$pee = preg_replace("|<p>(<li.+?)</p>|", "$1", $pee); // problem with nested lists
$pee = preg_replace('|<p><blockquote([^>]*)>|i', "<blockquote$1><p>", $pee);
$pee = str_replace('</blockquote></p>', '</p></blockquote>', $pee);
$pee = preg_replace('!<p>s*(</?' . $allblocks . '[^>]*>)!', "$1", $pee);
$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)s*</p>!', "$1", $pee);
if ($br) {
$pee = preg_replace_callback('/<(script|style).*?</\1>/s', create_function('$matches', 'return str_replace("
", "<WPPreserveNewline />", $matches[0]);'), $pee);
$pee = preg_replace('|(?<!<br />)s*
|', "<br />
", $pee); // optionally make line breaks
$pee = str_replace('<WPPreserveNewline />', "
", $pee);
}
$pee = preg_replace('!(</?' . $allblocks . '[^>]*>)s*<br />!', "$1", $pee);
// *insertion* of img|figcaption|summary
$pee = preg_replace('!<br />(s*</?(?:p|li|div|dl|dd|dt|th|pre|td|ul|ol|img|figcaption|summary)[^>]*>)!', '$1', $pee);
if (strpos($pee, '<pre') !== false)
$pee = preg_replace_callback('!(<pre[^>]*>)(.*?)</pre>!is', 'clean_pre', $pee );
$pee = preg_replace( "|
</p>$|", '</p>', $pee );
return $pee;
}
// remove the original wpautop function
remove_filter('the_excerpt', 'wpautop');
remove_filter('the_content', 'wpautop');
// add our new html5autop function
add_filter('the_excerpt', 'html5autop');
add_filter('the_content', 'html5autop');
The results are not absolutely perfect but then neither is the original
wpautop
function. Certain ways of formatting the code will result in unwanted
trailing </p>
tags or a missing opening <p>
tags.
For example, to insert a figure with caption into a post you should avoid
adding the figcaption
on a new line because an image or link appearing before
the figcaption
will end up with a trailing </p>
.
<!-- this turns out ok -->
<figure>
<a href="#"><img src="image.jpg" alt="" /></a><figcaption>A figure caption for your reading pleasure</figcaption>
</figure>
<!-- this turns out not so ok -->
<figure>
<a href="#"><img src="image.jpg" alt="" /></a>
<figcaption>A figure caption for your reading pleasure</figcaption>
</figure>
Another example would be when beginning the contents of an aside
with a
paragraph. You’ll have to leave a blank line between the opening aside
tag
and the first paragraph.
<aside>
This content could be a pullquote or information that is tangentially related to the surrounding content. But to get it wrapped in a paragraph you have to leave those blank lines either side of it before the tags.
</aside>
Room for improvement
Obviously there are still a few issues with this because if you format your post content in certain ways then you can end up with invalid HTML, even if it doesn’t actually affect the rendering of the page. But it seems to be pretty close!
Leave a comment or email me if you are using this function and find there that are instances where it breaks down. I ran numerous tests and formatting variations to try and iron out as many problems as possible but it’s unlikely that I tried or spotted everything.
Hopefully someone with more PHP and WordPress experience will be able to
improve upon what I’ve been experimenting with, or find a simpler and more
elegant solution that retains the useful wpautop
functionality while allowing
for the use of HTML5 elements in posts. Please share anything you find!
CSS pseudo-element Solar System
This is a remix of another author’s idea of using CSS to make a classic model of our solar system. Here, I’ve relied on CSS pseudo-elements and generated content to render scale models of the solar system from simple markup of the raw information.
There are three demos for this experiment, which is based on Alex Giron’s original Our Solar System in CSS3.
- Basic demo: Reworking of original experiment
- Advanced demo: Scale model of the Solar System
- Advanced demo (keyboard support): Scale model of the Solar System
The basic demo uses only CSS and simple, semantic HTML to relatively faithfully reproduce Alex’s original result.
The advanced demo is a rough scale model of the Solar System. It uses the same HTML as the “basic demo” but makes extensive use of CSS pseudo-elements, generated content, and various bits of CSS3.
The advanced demo (keyboard support) is an attempt to provide keyboard support by introducing slight modifications to the HTML. I’ve commented out the animations in this version of the demo.
Why rework the original experiment?
I was curious to see if the same result could be achieved with simpler HTML, by relying on some newer CSS features.
I experimented a bit further with generated content, shadows, and the way the layout of the solar system is implemented. Doing this exposed me to some of the different ways modern browsers are implementing CSS3. I’ve described some of those differences and bugs below.
A scale model of the solar system
The main demo is a scale model of the solar system. It uses 3 different scales: one for the object diameters; one for the distance of the planets from the sun; and one for the orbital period of each planet.
Semantic HTML and Microdata
The HTML is a list where each list item contains a title and description. I’ve included some HTML Microdata to provide hooks for generated content.
<li id="earth" itemscope>
<h2 itemprop="object">Earth
<dl>
<dt>Description</dt>
<dd itemprop="description">Earth is an ocean planet. Our home world's abundance of water - and life - makes it unique in our solar system. Other planets, plus a few moons, have ice, atmospheres, seasons and even weather, but only on Earth does the whole complicated mix come together in a way that encourages life - and lots of it.</dd>
<dt>Diameter</dt>
<dd itemprop="diameter">12,755 <abbr title="kilometers">km</abbr></dd>
<dt>Distance from sun</dt>
<dd itemprop="distance">150×10<sup>6</sup> <abbr title="kilometers">km</abbr></dd>
<dt>Orbital period</dt>
<dd itemprop="orbit">365<abbr title="days">d</abbr></dd>
</dl>
</li>
CSS pseudo-elements and generated content
Pseudo-elements are used to produce the planets, Saturn’s ring, the planet names, and to add the scale information.
Given that the scales only make sense when CSS is loaded it isn’t appropriate to have the scales described in the HTML. Both demos use the same HTML but only one of them is a rough scale model. Therefore, in the scale model demo I’ve used generated content to present the ratios and append extra information to the headings.
header h1:after {content:": A scale model";}
header h2:after {content:"Planet diameters 1px : 1,220 km / Distance from sun 1px : 7,125,000 km / Orbital period 1s : 4d";}
#earth dd[itemprop=diameter]:after {content:" (5px) / ";}
#earth dd[itemprop=distance]:after {content:" (22px) / ";}
#earth dd[itemprop=orbit]:after {content:" (91s)";}
Even more complex 3D presentations are likely to be possible using
webkit-perspective
and other 3D transforms.
Keyboard support
With a little modification it is possible to provide some form of keyboard support so that the additional information and highlighting can be viewed without using a mouse. Doing so requires adding block-level anchors (allowed in HTML5) and modifying some of the CSS selectors.
Modern browser CSS3 inconsistencies
This experiment only works adequately in modern browsers such as Safari 4+, Chrome 4+, Firefox 3.6+ and Opera 10.5+.
Even among the current crop of modern browsers, there are bugs and varying
levels of support for different CSS properties and values. In particular,
webkit’s box-shadow
implementation has issues.
There are a few other unusual :hover
bugs in Opera 10.5 (most obvious in the
basic demo). It should also be noted that the :hover
area remains square
in all modern browsers even when you apply a border-radius
to the element.
Border radius
There are also a few other peculiarities around percentage units for border
radius. Of the modern browsers, a square object with a border-radius
of 50% will
only produce a circle in Safari 5, Chrome 5, and Firefox 3.6.
Safari 4 doesn’t appear to support percentage units for border radius at all
(which is why the CSS in the demos explicitly sets a -webkit-border-radius
value for each object). Safari 5 and Chrome 5 do support percentage units for
this property. However, Chrome 5 has difficulty rendering a 1px wide border on
a large circle. Most of the border simply isn’t rendered.
In Opera 10.5, if you set border-radius
to 50% you don’t always get a circle,
so I have had to redeclare the border-radius
for each object in pixel units.
border-radius:50%
It appears that this is one aspect of Opera’s non-prefixed border-radius
implementation that is incorrect and in need of fixing.
Box shadow
Safari 4’s inferior box-shadow
implementation means that inset shadows are
not rendered on the planet bodies. In addition, the second box-shadow
applied
to Saturn (used to separate the planet from its ring) is completely missing in
Safari 4 as it does not support a spread radius value.
Safari 5 and Chrome 5 are better but still problematic. The second box-shadow
is not perfectly round as the box-shadow
seems to use the pseudo-element’s
computed border-radius
. Furthermore, Chrome 5 on Windows does not properly
support inset box-shadow
meaning that the shadow ignores the border-radius
declaration and appears as a protruding square.
box-shadow
The use of box-shadow
to separate Saturn from the ring isn’t strictly
necessary. You can create the separated ring using a border but box-shadow
cannot be applied in a way that casts it over a border. Another alternative
would be to add a black border around the planet to give the illusion of space
between itself and the ring, but all browsers display a few pixels of unwanted
background colour all along the outer edge of the rounded border.
I wanted the ring to share the appearance of a shadow being cast on it. Opera 10.5 and Firefox 3.6 get it right. Both webkit browsers get it wrong.
CSS image replacement. One more time.
An accessible image replacement method using pseudo-elements and generated-content. This method works with images and/or CSS off, with semi-transparent images, doesn’t hide text from screen-readers or search engines, and provides fallback for IE 6 and IE 7.
Known support: Firefox 1.5+, Safari 3+, Chrome 3+, Opera 9+, IE 8+
What’s wrong with current methods?
The two most widely used image replacement techniques are the Gilder/Levin Method and the Phark Method. Both have different flaws.
The Gilder/Levin Method requires the addition of presentational HTML (an empty
span
) and doesn’t work with transparent images as the default text shows
through. The Phark Method uses a negative text-indent to hide the text and so
it is not visible when CSS is on and images are off.
Resurrecting the NIR method
Using pseudo-elements and generated-content as an image replacement technique isn’t a new idea. It was proposed and demonstrated by Paul Nash back in 2006. This is the Nash Image Replacement method.
<h1 class="nir">[content]</h1>
.nir {
height: 100px; /* height of replacement image */
padding: 0;
margin: 0;
overflow: hidden;
}
.nir:before {
content: url(image.gif);
display: block;
}
The height
value is equal to that of the replacement image. Setting
overflow:hidden
ensures that the original content is not visible on screen
when the image is loaded. The replacement image is inserted as generated
content in the :before
pseudo-element which is set to behave like a block
element in order to push the element’s original content down.
What about IE 6 and IE 7?
Neither browser supports :before
; if you need to support them you’ll have to
rely on the Phark method. This can be done using conditional comments or safe
IE6/7 hacks to serve alternative styles to legacy versions of IE .
<!--[if lte IE 7]>
<style>
.nir {
height: 100px;
padding: 0;
margin: 0;
overflow: hidden;
text-indent: -9000px;
background: url(image.gif) no-repeat 0 0;
}
</style>
<![endif]-->
Using the NIR method allows you to keep your HTML semantic and deliver improved accessibility to users of modern browsers. The Phark Method can then be served to IE 6 and IE 7.
Improving the NIR
method
The first problem with NIR is that if images are disabled all browsers leave whitespace above the element’s content. Opera 10.5 even displays the text string “image”! If the height of the element is small enough this whitespace causes the element’s content to overflow and be partially or completely hidden when images are disabled.
Another consideration is what happens if an image doesn’t exist or fails to load. Safari and Chrome will display a “missing image” icon that cannot be removed. Once again, this can cause the element’s content to overflow and become partially or completely hidden to users.
A more robust version of the NIR method is the following modification:
.nir {
height: 100px; /* height of replacement image */
width: 400px; /* width of replacement image */
padding: 0;
margin: 0;
overflow: hidden;
}
.nir:before {
content: url(image.gif);
display: inline-block;
font-size: 0;
line-height: 0;
}
Setting font-size
and line-height
to 0
avoids the whitespace problems in
all browsers. Setting the element’s width
equal to that of the replacement
image and getting the pseudo-element to act as an inline-block
helps minimise
the problems in webkit browsers should an image fail to load.
Ideally browsers would avoid displaying anything in a pseudo-element when its generated-content image fails to load. If that were the case, the original NIR method would be all that is needed.
What about using sprites?
One of the most common uses of image replacement is for navigation. This often
involves using a large sprite with :hover
and :active
states as a
background image. It turns out that using sprites is not a problem for modern
browsers. When using the modified-NIR method the sprite is
included as a generated-content image that is positioned using negative
margins.
This is an example that rebuilds the right-hand category navigation from Web Designer Wall using a sprite and the modified-NIR method.
<ul id="nav">
<li id="nav-item-1"><a href="#non">Tutorials</a></li>
<li id="nav-item-2"><a href="#non">Trends</a></li>
<li id="nav-item-3"><a href="#non">General</a></li>
</ul>
/* modified-NIR */
#nav a {
display: block;
width: 225px;
height: 46px;
overflow: hidden;
}
#nav a:before {
content:url(sprite.png);
display:-moz-inline-box; /* for Firefox 1.5 & 2 */
display:inline-block;
font-size:0;
line-height:0;
}
/* repositioning the sprite */
#nav-item-1 a:hover:before,
#nav-item-1 a:focus:before,
#nav-item-1 a:active:before {margin:-46px 0 0;}
#nav-item-2 a:before {margin:-92px 0 0;}
#nav-item-2 a:hover:before,
#nav-item-2 a:focus:before,
#nav-item-2 a:active:before {margin:-138px 0 0;}
#nav-item-3 a:before {margin:-184px 0 0;}
#nav-item-3 a:hover:before,
#nav-item-3 a:focus:before,
#nav-item-3 a:active:before {margin:-230px 0 0;}
/* :hover hack for IE8 if no a:hover styles declared */
#nav a:hover {cursor:pointer;}
For some reason IE8 refuses to reposition the image when the mouse is over the
link unless a style is declared for a:hover
. In most cases you will have
declared a:hover
styles for the basic links on your webpage, and this is
enough. But it is worth being aware of this IE8 behaviour.
The addition of display:-moz-inline-box;
is required to reposition the sprite
in versions of Firefox prior to Firefox 3.0. They are very rare browsers but
I’ve included it in case that level of legacy support is needed.
If you want image replacement in IE 6 and IE 7 the following additional styles can be served to those browsers using conditional comments.
/* Phark IR method */
#nav a {
text-indent: -9000px;
background: url(sprite.png) no-repeat;
}
/* repositioning the sprite */
#nav-item-1 a:hover,
#nav-item-1 a:active { background-position: 0 -46px; }
#nav-item-2 a { background-position: 0 -92px; }
#nav-item-2 a:hover,
#nav-item-2 a:hover { background-position: 0 -138px; }
#nav-item-3 a { background-position: 0 -184px; }
#nav-item-3 a:hover,
#nav-item-3 a:active { background-position: 0 -230px; }
/* hack for IE6 */
#nav a:hover { margin: 0; }
The changes are fairly simple. But IE 6 applies the margins declared for
a:hover:before
to a:hover
and so they need to be reset in the styles served
to IE 6.
See the modified-NIR (using sprites) demo.