Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NHS logo PNG fallback HTML validation errors #572

Closed
chrimesdev opened this issue Dec 3, 2019 · 3 comments
Closed

NHS logo PNG fallback HTML validation errors #572

chrimesdev opened this issue Dec 3, 2019 · 3 comments
Labels
🕙 hours A well understood issue which we expect to take less than a day to resolve header help wanted Extra attention is needed 🔍 investigation
Milestone

Comments

@chrimesdev
Copy link
Member

chrimesdev commented Dec 3, 2019

Description

The NHS (SVG) logo in the Header has a PNG fallback for Internet Explorer 8 (which doesn't support SVG logos). The way we do this is by using the <image> element with a src attribute pointing to our PNG fallback, along with an empty xlink:href attribute to ensure that Internet Explorer 11/10 does not download both the SVG and the PNG logos. This is following the guidance on: https://css-tricks.com/a-complete-guide-to-svg-fallbacks/#fallback-inline-svg-imgtag

"In most browsers, therefore, it is sufficient to include an tag with a src attribute (pointing to your fallback image) inside your inline SVG: the old browsers will download the fallback, the new browsers won't. Except for Internet Explorer, which downloads the fallback image even when it doesn't display it. The solution is to put a null xlink:href attribute on the element. The IE developer tools still show it requesting the fallback, but it aborts almost immediately (<1ms in IE11 or IE10/IE9 emulation mode), before downloading anything."

However when running the Header component (https://nhsuk.github.io/nhsuk-frontend/components/header/index.html) through an HTML validator (https://validator.w3.org/) there are 3 errors found on the <image> element:

Error: Attribute src not allowed on element image at this point.
Error: Element image is missing required attribute height.
Error: Element image is missing required attribute width.

The first error, attribute src not allowed on element image at this point, looks like it might be unavoidable validation error from early investigation (could be worth investigating further). But we could possibly look at adding an height and width attribute to the <image> fallback element to fix the remaining 2 errors.

Initially it looks like adding width="40" height="100" to <image src="https://assets.nhs.uk/images/nhs-logo.png" xlink:href="" width="40" height="100"></image> works fine. But when testing this on Internet Explorer 9 and 10, it gives an empty box overlaying the header:

Screenshot 2019-12-03 at 11 12 34

Setting the width and the height sizing with CSS on the fallback image doesn't seem to change much either. We could possibly display: none the fallback image on everything expect .ie8.

It would be good to investigate if we can fix any (or all) of these HTML validation errors.

Related

GOV.UK Frontend have managed to fix the height and width validation errors, without the strange empty box overlay, so this may be something to do with our SVG markup or styling. (https://github.com/alphagov/govuk-frontend/blob/master/package/govuk/components/header/template.njk#L42).

The attribute src not allowed on element image at this point error, seems to still be an issue there also.

@chrimesdev chrimesdev added awaiting triage Needs triaging by team 🔍 investigation 🕙 hours A well understood issue which we expect to take less than a day to resolve Priority: low and removed awaiting triage Needs triaging by team labels Dec 3, 2019
@chrimesdev chrimesdev added the help wanted Extra attention is needed label Mar 21, 2020
@mcheung-nhs
Copy link
Collaborator

We will be looking to drop support for IE8 due to our very very low number of visitors (i.e. zero) using this browser so this will remove the png fallback.

@chrimesdev chrimesdev added this to the 5.0.0 milestone Jan 13, 2021
@mcheung-nhs
Copy link
Collaborator

mcheung-nhs commented Jan 19, 2021

The png will be removed as part of #696

@chrimesdev
Copy link
Member Author

This will be fixed in release 5.0.0 (next week)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🕙 hours A well understood issue which we expect to take less than a day to resolve header help wanted Extra attention is needed 🔍 investigation
Projects
None yet
Development

No branches or pull requests

3 participants