lace

Another CSS image replacement technique

A new image replacement technique was recently added to the HTML5 Boilerplate project. This post explains how it works and how it compares to alternative image replacement techniques.

[15 December 2012] This technique is no longer used in HTML5 Boilerplate. It’s been replaced by another, more reliable approach.

Here’s the CSS behind the recent update to the image replacement helper class in HTML5 Boilerplate. It has also made its way into the Compass framework.

.ir {
  font: 0/0 a;
  text-shadow: none;
  color: transparent;
}

What does each declaration do?

  • font:0/0 a – a shorthand property that zeros out the font size and line-height. The a value acts as a very short font-family (an idea taken from the BEM implementation of this method). The CSS validator complains that using 0/0 in the shorthand font property is not valid, but every browser accepts it and this appears to be an error in the validator. Using font:0px/0 a passes validation but it displayed as font:0/0 a in the code that the validator flags as valid.
  • text-shadow:none – makes sure that any inherited text shadow is removed for the text. This prevents the chance of any text shadow colors showing over the background.
  • color:transparent – needed for browsers than don’t completely crush the text to the point of being invisible. Safari 4 (extremely rare) is an example of such a browser. There may also be mobile browsers than require this declaration. IE6/7/8 don’t recognise this value for color, but fortunately IE7/8 don’t show any trace of the text. IE6 shows a faint trace.

In the HTML5 Boilerplate image replacement helper, we’ve also removed any border and background-color that may be on the element. This makes it easier to use the helper class on elements like button or with links that may included background or border properties as part of a design decision.

Benefits over text-indent methods

The new technique avoids various problems with any text-indent method, including the one proposed by Scott Kellum to avoid iPad 1 performance problems related to large negative text indents.

  • Works in IE6/7 on inline-block elements. Techniques based on text indentation are basically “broken”, as shown by this test case: http://jsfiddle.net/necolas/QZvYa/show/
  • Doesn’t result in any offscreen box being created. The text-indent methods result in a box being drawn (sometimes offscreen) for any text that have been negatively or positively indented. It can sometimes cause performance problems but the font-based method sidesteps those concerns.
  • No need to specify a text-alignment and hide the overflow since the text is crushed to take up no space.
  • No need to hide br or make all fallback HTML display:inline to get around the constraints of using a text indentation. This method is not affected by those problems.
  • Fewer styles are needed as a result of these improvements.

Drawbacks

No image replacement hack is perfect.

  • Leaves a very small trace of the text in IE6.
  • This approach means that you cannot use em units for margins on elements that make use of this image replacement code. This is because the font size is set to 0.
  • Windows-Eyes has a bug that prevents the reading of text hidden using this method. There are no problems with all other screenreaders that have been tested. Thanks to @jkiss for providing these detailed results and to @wilto for confirming this technique works for JAWS 12 in IE 6/7/8 and Firefox 4/5/6.
  • Like so many IR methods, it doesn’t work when CSS is loaded but images are not.
  • Text may not be hidden if a visitor is using a user style sheet which has explicitly set important font-size declarations for the element type on which you have applied the IR class.

It’s worth noting that the NIR image replacement technique avoids these drawbacks, but lacks support in IE6/7.

Closing comments

I’ve been using this technique without significant problems for nearly a year, ever since Jonathan Neal and I used it in a clearfix experiment. The BEM framework also makes use of it for their icon components. The core idea was even proposed back in 2003 but the browser quirks of the day may have prevented wider use.

If you come across any problems with this technique, please report them at the HTML5 Boilerplate GitHub issue tracker and include a test case when appropriate.

Translations




lace

The stirring of soul in the workplace [electronic resource] / Alan Briskin

Briskin, Alan, 1954-




lace

The Tech Professional's Guide to Communicating in a Global Workplace [electronic resource] : Adapting Across Cultural and Gender Boundaries / by April Wells

Wells, April. author




lace

Technology entrepreneurship [electronic resource] : taking innovation to the marketplace / Thomas N. Duening, Ph.D, El Pomar Chair of Business and Entrepreneurship, Director, Center for Entrepreneurship, College of Business, University of Colorado at Colo

Duening, Thomas N




lace

Thriving under stress [electronic resource] : harnessing demands in the workplace / Thomas W. Britt, Ph.D., Professor of Psychology, Clemson University, Steve M. Jex, Ph.D., Professor of Psychology, Bowling Green State University

Britt, Thomas W., 1966-




lace

Tivoli Storage Manager V6.1 Technical Guide [electronic resource] / Mary Lovelace and 6 others

Lovelace, Mary




lace

Turn enemies into allies [electronic resource] : the art of peace in the workplace / Judy Ringer ; foreword by James Warda ; illustrations by Adam Richardson

Ringer, Judy, 1949- author




lace

Us vs. them [electronic resource] : redefining the multi-generational workplace to inspire your employees to love your company, drive innovation, and embrace change / Jeff Havens

Havens, Jeff, author






lace

JAMA Cardiology : Utility of 90-Day vs 30-Day Mortality Quality Metrics for Aortic Valve Replacement Outcomes

Interview with Tsuyoshi Kaneko, MD, and Sameer A Hirji, MD, authors of Utility of 90-Day Mortality vs 30-Day Mortality as a Quality Metric for Transcatheter and Surgical Aortic Valve Replacement Outcomes, and Michael J. Mack, MD, author of Ninety-Day Outcome Assessment After Transcatheter and Surgical Aortic Valve Replacement—Is the Juice Worth the Squeeze?




lace

Ex-Disney workers replaced by H1-B visa holders file complaint



  • DO NOT USE Indians Abroad
  • World

lace

Double addition of phenylacetylene onto the mixed bridge phosphinito–phosphanido Pt(I) complex [(PHCy2)Pt(μ-PCy2){κ2P,O-μ-P(O)Cy2}Pt(PHCy2)](Pt–Pt)

Dalton Trans., 2020, Advance Article
DOI: 10.1039/D0DT00923G, Paper
Stefano Todisco, Mario Latronico, Vito Gallo, Nazzareno Re, Alessandro Marrone, Iogann Tolbatov, Piero Mastrorilli
Double addition of phenylacetylene onto the Pt(I)–Pt(I) complex [(PHCy2)Pt(μ-PCy2){κ2P,O-μ-P(O)Cy2}Pt(PHCy2)] (Pt–Pt) affords the η1-alkenyl-μ,η12-alkynyl complex [(η1-trans-(Ph)HCCH)(PHCy2)Pt(μ-PCy2)(μ,η12-PhCC)Pt{κP-P(O)Cy2}(PHCy2)].
To cite this article before page numbers are assigned, use the DOI form of citation above.
The content of this RSS Feed (c) The Royal Society of Chemistry




lace

What is a “third place,” and do you have one?

The term “happy place” is not in the Oxford English Dictionary (though “happy slap” is), but I’ve been hearing the term a lot. There’s even a new shop in Great Barrington called HappyPlace Berkshires. I first dismissed it as therapeutic slang, but discovered that the concept actually goes back to the Greeks: a utopia is

The post What is a “third place,” and do you have one? appeared first on Berkshire Publishing.




lace

Armed conflict and forcible displacement: individual rights under international law / edited by Elena Katselli Proukaki

Dewey Library - KZ6530.A75 2018




lace

Indian water in the new West / Thomas R. McGuire, William B. Lord, Mary G. Wallace, editors

Online Resource




lace

Handling climate displacement / Khaled Hassine, United Nations, Geneva

Dewey Library - K3585.5.H37 2019




lace

Natural resources law: a place-based book of problems and cases / Christine A. Klein, University of Florida, Levin College of Law; Federico (Fred) Cheever, University of Denver, Sturm College of Law; Bret C. Birdsong, University of Nevada, Las Vegas, Will

Dewey Library - KF5505.K58 2018




lace

Reimagining administrative justice: human rights in small places / Margaret Doyle, Nick O'Brien

Dewey Library - K3400.D69 2020




lace

Industrial Placement - Defence Security Analysis Division: Defence Science and Technology Laboratory

£Attractive: Defence Science and Technology Laboratory
For more latest jobs and jobs in South West England visit brightrecruits.com



  • South West England

lace

Industrial Placement - Counter Terrorism and Security Division: Defence Science and Technology Laboratory

£Attractive: Defence Science and Technology Laboratory
For more latest jobs and jobs in South West England visit brightrecruits.com



  • South West England

lace

New Chinese-language documentaries : ethics, subject and place / Kuei-fen Chiu and Yingjin Zhang

Chiu, Kuei-fen, author




lace

Another place another time = Yi yu / Chan-Fai Cheung ; with an essay by Ľubica Učník ; Chinese essays by Donna Chu, Chan-Fai Cheung

Zhang, Canhui, 1949- author, photographer




lace

Governments are slow to put in place the policies we need for adaptation to climate change

Policies aimed at adaptation will help the world build resilient highways and other infrastructure




lace

University of Oklahoma natural product chemist finds novel molecules in unexpected places

Robert Cichewicz looks off the beaten path for unusual plant and fungi compounds




lace

Chemists are finding their place on TikTok

Educators, researchers, and students are coming together to share chemistry demos and talk shop on the wildly popular video app




lace

China's new place on the front lines of diagnosing and treating coronavirus disease

Industry watchers say the effort is unprecedented and would not have been possible during the last SARS outbreak




lace

Dipharma places a kilo lab in Kalamazoo




lace

Pentachlorophenol is on its way out as a utility pole preservative. Here's what might take its place

Phaseout is pushing a slow-to-change industry to look at alternatives




lace

CFC replacements are a source of persistent organic pollution in the Arctic

Analysis of ice cores shows increasing levels of three short-chain PFAS linked to CFC replacement chemicals




lace

CFC replacements are a source of persistent organic pollution in the Arctic

Analysis of ice cores shows increasing levels of 3 short-chain PFAS linked to replacements of CFCs




lace

Students will take the Advanced Placement chemistry exam in a modified format

Decision to move forward during COVID-19 pandemic relieves some but also raises concerns about cheating




lace

Manu Bhaker gets electronic target installed at home in place of manual machine

Manu Bhaker was sure in her mind that the Olympics will take place next year despite the uncertainty in the world of sports due to the COVID-19 pandemic.




lace

Birthplace of the atomic bomb: a complete history of the Trinity Test Site / William S. Loring

Hayden Library - QC773.3.U5 L66 2019




lace

Part 2 – Ch30 – The Place Of Coolness

These are the recordings of the complete collection of all the talks by Ajahn Chah that have been translated into English and are published in 'The Collected Teachings of Ajahn Chah', 2011. This was read by Ajahn Amaro during the winter of 2012

The post Part 2 – Ch30 – The Place Of Coolness appeared first on Amaravati Buddhist Monastery.




lace

Compliance with COVID-19 social-distancing measures in Italy [electronic resource] : the role of expectations and duration / Guglielmo Briscese, Nicola Lacetera, Mario Macis, Mirco Tonin

Cambridge, Mass. : National Bureau of Economic Research, 2020




lace

Greens protest over littering of public places

People have been littering a road at Babugudda by throwing waste every day even when a group of nature lovers in the city has been carrying out cleanliness drive regularly there. The group had also planted hundreds of saplings to make the area, which is adjacent to a crematorium, clean. However, people continue to throw garbage not bothering about the campaigns of greens.




lace

Transit-oriented displacement or community dividends?: understanding the effects of smarter growth on communities / Karen Chapple and Anastasia Loukaitou-Sideris

Rotch Library - HT241.C424 2019




lace

Rethinking third places: informal public spaces and community building / edited by Joanne Dolley, Caryl Bosman

Rotch Library - HT185.R48 2019




lace

Inhabiting the sacred in everyday life: how to design a place that touches your heart, stirs you to consecrate and cultivate it as home, dwell intentionally within it, slay monsters for it, and let it loose in your democracy / Randolph T. Hester, Jr. and

Rotch Library - HT167.H47 2019




lace

Placemaking fundamentals for the built environment / Dominique Hes, Cristina Hernandez-Santin, editors

Online Resource




lace

Changing places: the science and art of new urban planning / John MacDonald, Charles Branas, Robert Stokes

Rotch Library - HT166.M233 2019




lace

Business improvement districts and the contradictions of placemaking: BID urbanism in Washington, D.C. / Susanna F. Schaller

Rotch Library - HT177.W3 S33 2019




lace

Black in place: the spatial aesthetics of race in a post-Chocolate City / Brandi Thompson Summers

Rotch Library - HT177.W3 S84 2019




lace

Creating great places: evidence-based urban design for health and wellbeing / Debra Flanders Cushing and Evonne Miller

Rotch Library - HT166.C8845 2020




lace

Migrants from Bihar return to workplaces

Buses arranged to take them to their places of work




lace

BMC commissioner transferred, Chahal to replace Pardeshi

Action taken a day after Central team’s visit; Opposition slams government




lace

Tamil Nadu Chief Minister urges Prime Minister Modi to place amendments to Electricity Act in abeyance

In a letter to the Prime Minister, Edappadi K. Palaniswami reiterated that Tamil Nadu was committed to providing free electricity supply to farmers, and said the Bill could affect this policy




lace

Trump administration shelves CDC guide to reopen public places: Report

The guidance contained detailed advice for making site-specific decisions related to reopening schools, restaurants, summer camps, churches, day care centers and other institutions




lace

Bollywood finds a place in Iranian hearts

Indian films, and Raj Kapoor in particular, have a special place in Iranian cinephilia or cinemadoosti, Ranjita Ganesan discovers on a visit to Iran.