├── .editorconfig ├── .gitignore ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── accessibility ├── 01-popular-tools.md ├── 02-guide-to-alt-text.md ├── 03-accessibility-in-emails.md ├── 04-accessibility-in-pdfs.md ├── 05-effective-colour-contrast.md ├── 06-accessibility-checklist.md ├── 07-guide-for-suppliers.md ├── README.md ├── common-remediations │ ├── README.md │ ├── colours.md │ ├── controls.md │ ├── focus-management.md │ ├── headings.md │ ├── high-magnification.md │ ├── html-attributes.md │ ├── images.md │ ├── keyboard-navigation.md │ ├── language-of-page-and-parts.md │ ├── page-titles.md │ └── semantics.md └── images │ ├── alt-examples │ ├── akkadian.png │ ├── bell.png │ ├── maths.png │ ├── orlok.png │ └── virus.png │ ├── color_contrast_01.jpg │ ├── color_contrast_02.gif │ ├── color_contrast_03.gif │ ├── color_contrast_04.gif │ ├── color_contrast_05.gif │ └── microsoft-accessibility.jpg ├── css ├── README.md ├── bem-css.md ├── config │ └── .stylelintrc ├── house-style.md └── how-we-write-css.md ├── git ├── README.md ├── git.md └── semver.md ├── javascript ├── README.md └── house-style.md ├── learning ├── README.md ├── web-accessibility.md └── web-performance.md ├── markup ├── README.md └── house-style.md ├── performance ├── README.md ├── advertising.md ├── browser-caching.md ├── font-loading.md ├── images.md └── performance-checklist.md ├── practices ├── README.md ├── code-review.md ├── graded-browser-support.md ├── house-style.md ├── javascript-styling.md ├── managing-node-projects.md ├── managing-static-assets.md ├── open-source-support.md ├── progressive-enhancement.md └── structured-data.md ├── security ├── README.md └── secure-markup.md └── writing ├── README.md ├── house-style.md ├── inclusive-language.md └── social-media.md /.editorconfig: -------------------------------------------------------------------------------- 1 | # http://editorconfig.org 2 | root = true 3 | 4 | [*] 5 | charset = utf-8 6 | end_of_line = lf 7 | indent_size = 4 8 | indent_style = tab 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | [*.json] 13 | insert_final_newline = false 14 | indent_size = 2 15 | indent_style = space 16 | 17 | [*.md] 18 | indent_size = 2 19 | indent_style = space 20 | trim_trailing_whitespace = false 21 | 22 | [*.yml] 23 | indent_size = 2 24 | indent_style = space 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.idea/ 2 | *.iml 3 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing to the Frontend Playbook 2 | 3 | If you're on this page because you'd like to contribute to the Playbook, that's fantastic! Thank you for getting involved ❤️ 4 | 5 | Contributing to the Playbook is for everyone. Whether you work at Springer Nature or not, the Playbook is for you - a guide to good working standards and practices that support healthy, happy teams. You don't need to be a developer to get involved. We cover many areas, from cultural and technical writing to specific technical practices. Please adhere to our [house style](writing/house-style.md) and [inclusive language](writing/inclusive-language.md) guidelines when you make your contributions. 6 | 7 | ## How do I contribute? 8 | 9 | ### Discussing 10 | 11 | You can get involved in discussions in issues and pull requests. Sometimes we need a discussion to [come to an agreement](https://github.com/springernature/frontend-playbook/issues/92) on a particular issue before a pull request is opened. Sometimes [a pull request](https://github.com/springernature/frontend-playbook/pull/87) will be discussed. Both types of discussion help bring us to a common understanding, and your input at this stage is really valuable. 12 | 13 | ### Opening and assigning issues 14 | 15 | [Our issues list](https://github.com/springernature/frontend-playbook/issues) is half to-do list, half discussion. Not every issue will produce a pull request, and some issues may produce multiple pull requests. 16 | 17 | Create an issue if you notice that there's something missing from the Playbook. If you'd like to discuss the issue with others, use a label like "collaboration", "help wanted", or "question". If you intend to open a pull request to resolve the issue you've created, consider assigning the issue to yourself. 18 | 19 | A good issue is [sufficiently detailed](https://github.com/springernature/frontend-playbook/issues/45) for anybody to be able to understand what it's about. If there are existing issues already created that are related to yours, then please link to them to provide further context. 20 | 21 | ### Opening pull requests 22 | 23 | Please create a new short-lived feature branch for your changes, then create a pull request. Once your changes have been approved, you can merge them to the default branch. [Read more about what we're looking for when we review](practices/code-review.md). 24 | 25 | Include a summary of your pull request when you open it. We prefer to use commit messages to explain _what_ a change will do, and pull request summaries to explain _why_ the change was made. [Read further guidelines on commit messages](git/git.md) - many of these guidelines can also apply to pull request summaries! 26 | 27 | If you work at Springer Nature, please remember to keep discussion inside the issues and pull requests, avoiding Slack, hallway conversations etc. Remember that this repo is public, and the discussions we have can be of benefit to people apart from us. 28 | 29 | ### Merging pull requests 30 | With short-lived feature branches, a key rule is that [branches should be quickly merged and deleted](https://trunkbaseddevelopment.com/short-lived-feature-branches/). 31 | 32 | With a playbook PR, __this rule does not apply__. The aim is to get many people reading or contributing-to the pull request (and the likelihood of a conflict upon merge is very very low). 33 | 34 | Because of this, it is fine (in many cases highly _desired_) to propose something, then wait a week or so before reminding people that there is a PR open. Let people know you'll be merging in a week or so, assuming there's no continuing discussion. That way, more people will have a chance to contribute. 35 | 36 | ### Publicising your changes 37 | 38 | A bot notifies the #frontend Slack room when work is merged, because changes to the playbook are relevant to all Frontend developers at Springer Nature. 39 | 40 | We hope the wider development community will be interested in the work we have committed here. We welcome feedback and involvement from all - so feel free to link to your latest contribution on your social media platform of choice. 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # The Frontend Playbook 2 | 3 | This repo contains The Frontend Playbook. It details how we run software development and how we make web and mobile products together. It's filled with things we've learned based on our own experience and study of others' experiences. 4 | 5 | The main motivator for this playbook is not to document a list of guidelines, but rather to create an opportunity to collaborate on them, and to gain consensus. 6 | 7 | This is a living document that we contribute to in a _public_ GitHub repo. Reasons for doing this in the open include (but are not limited to): 8 | 9 | 1. Interacting with and learning from others. Receiving contributions from people who don't work here can help us, providing learning opportunities that we would not receive otherwise - for example, see [this contribution](https://github.com/springernature/frontend-playbook/pull/48#issuecomment-236139605) from @rowanmanning. 10 | 11 | 1. Providing a showcase for our work/ethics. This is _really_ useful when hiring people (for both parties). We've had very positive feedback from interviewees - it's a great recruiting tool. It also means that people are quickly up and running when they join. 12 | 13 | See "[Changing the laws of engineering with pull requests](https://www.youtube.com/watch?v=YIpNpptGX6Q)" for an in depth explanation of how developing a playbook like this is of benefit. 14 | 15 | ## Sections 16 | 17 | There's no particular order to which you should read the playbook, but the [Practices section](practices/README.md) is probably a good starting point. 18 | 19 | * [Accessibility](accessibility/README.md) 20 | * [CSS](css/README.md) 21 | * [Git](git/README.md) 22 | * [JavaScript](javascript/README.md) 23 | * [Markup](markup/README.md) 24 | * [Performance](performance/README.md) 25 | * [Practices](practices/README.md) 26 | * [Security](security/README.md) 27 | * [Writing](writing/README.md) 28 | 29 | ## Contributing 30 | 31 | To contribute please clone the repo (or fork it if you're an external contributor), create a new branch for your changes, then create a pull request to merge your changes in. 32 | 33 | Please keep discussion inside the issues and pull requests, avoiding Slack, hallway conversations etc. Remember that this repo is public, and the discussions we have can be of benefit to people apart from us. 34 | 35 | [Read the full contributor guide](CONTRIBUTING.md). 36 | 37 | ## Key words 38 | 39 | The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [BCP (Best Current Practice) 14](https://www.rfc-editor.org/info/bcp14) ([RFC 2119](https://tools.ietf.org/html/rfc2119), [RFC8174](https://tools.ietf.org/html/rfc8174)) when, and only when, they appear in all capitals, as shown here. 40 | 41 | ## License 42 | 43 | The Frontend Playbook is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License. 44 | 45 | You should have received a copy of the license along with this work. If not, see [Creative Commons BY-NC-SA 4.0 license](http://creativecommons.org/licenses/by-nc-sa/4.0/). 46 | -------------------------------------------------------------------------------- /accessibility/01-popular-tools.md: -------------------------------------------------------------------------------- 1 | # Accessibility tools 2 | 3 | - [Automated testing](#automated-testing) 4 | - [Pa11y and axe](#pa11y-and-axe) 5 | - [Manual testing](#manual-testing) 6 | - [Assistive technology](#assistive-technology) 7 | - [Screen readers](#screen-readers) 8 | - [Other accessibility tools](#other-accessibility-tools) 9 | - [Automated accessibility testing tools in the browser](#automated-accessibility-testing-tools-in-the-browser) 10 | - [Tools for manually analysing web pages](#tools-for-manually-analysing-web-pages) 11 | - [Tools for audio and video media accessibility](#tools-for-audio-and-video-media-accessibility) 12 | - [Simulators](#simulators) 13 | 14 | ## Automated testing 15 | 16 | Automated accessibility testing can be used to detect the most common accessibility problems. This is only the first step in the process; you MUST NOT rely on automated testing as your sole method of validation! None of these tools on their own will catch every error. Even by combining all of them, it's still possible to produce an inaccessible webpage. 17 | 18 | Terrill Thompson [compared several of the most popular tools](http://terrillthompson.com/blog/730) which should give you some idea of the scale of the problem. The GDS Accessibility team ran an experiment in 2017 to [audit the performance of a large number of available automated accessibility testing tools](https://accessibility.blog.gov.uk/2017/02/24/what-we-found-when-we-tested-tools-on-the-worlds-least-accessible-webpage/). They found that the highest number of errors that one tool was able to detect was 40%. The majority of the tools fell into the 20%-30% range. 19 | 20 | You MUST NOT rely on automated accessibility testing tools as your sole safeguard for accessibility testing. 21 | 22 | 23 | ### Pa11y and axe 24 | 25 | We use [Pa11y](http://pa11y.org/) to perform automated accessibility testing. Pa11y is an automated accessibility testing tool that supports [HTML_Codesniffer](https://squizlabs.github.io/HTML_CodeSniffer/) by Squizlabs, and [axe](https://www.deque.com/axe/) by Deque. 26 | 27 | Projects MUST have Pa11y integrated at the build stage, and builds MUST fail if errors are introduced. You MUST NOT allow accessibility regressions to enter your project's codebase. We're aiming to make accessibility better, so our baseline is to not make it worse. 28 | 29 | Mature projects using Pa11y for the first time MAY use the `threshold` flag to specify a baseline number of errors to allow through, but MUST aim to reduce that threshold to zero at the earliest opportunity. [Watch this talk by Laura Carvajal of the Financial Times](https://www.youtube.com/watch?v=H4FzW9oFObs) to get a high level overview of the concept. 30 | 31 | Read [Automated accessibility testing with Travis CI](http://cruft.io/posts/automated-accessibility-testing-node-travis-ci-pa11y/) to see how to integrate Pa11y with your build process. If you're not using Travis, adjust the setup for the software that you are using. 32 | 33 | You can use HTML_Codesniffer or axe as your test suite; we recommend using both. Neither engine is "better" than the other, they just use different testing strategies. When you fail builds based on Pa11y results, bear in mind that the two testing engines return different numbers of results, and their results are formatted differently. 34 | 35 | If you're a VS Code user, you can also install Deque's [axe accessibility linter](https://marketplace.visualstudio.com/items?itemName=deque-systems.vscode-axe-linter) from the Visual Studio marketplace and catch some common accessibility errors before they get to the build stage. 36 | 37 | 38 | ## Manual testing 39 | 40 | Manual accessibility testing fills in the gaps that automated tools miss. 41 | 42 | - Microsoft’s [free Accessibility Insights tool](https://accessibilityinsights.io/) is a browser extension for Chrome that will guide you through the process of assessing a webpage for basic accessibility conformance. It's not a complete guide to accessibility, but will help you catch things that automated testing can't. 43 | 44 | 45 | ## Assistive technology 46 | 47 | You're encouraged to test your pages with assistive technology (AT). Many operating systems include some AT as standard, including screenreaders, magnifiers, or input remapping. 48 | 49 | Make sure you test your work at high magnification. You may also find navigating without an input device using [Voice Control](https://support.apple.com/en-au/HT210539) instructive. Ensure your interfaces work with keyboard navigation. 50 | 51 | ### Screen readers 52 | 53 | If you don’t use a screen reader regularly, the way that you use it will be different to that of a habitual screen reader user, so be cautious in extrapolating your own experiences to those of other users. But also bear in mind that not all regular screen reader users are experts or power users, just like not all users of web browsers are experts. 54 | 55 | If you’re a Mac user, VoiceOver is built-in to OSX and is a decent, basic screen reader. This guide from WebAIM [explains the basics of using VoiceOver to test pages](https://webaim.org/articles/voiceover/). 56 | 57 | If you’re a Windows user, NVDA is one of the more popular screen readers amongst blind users. This guide from WebAIM [explains the basics of using NVDA to test pages](https://webaim.org/articles/nvda/). 58 | 59 | On mobile, VoiceOver is built-in on iOS devices, and TalkBack is usually built-in on Android devices. 71% of respondents to the [WebAIM Screen Reader User Survey #8](https://webaim.org/projects/screenreadersurvey8/#mobilescreenreaders) use iOS VoiceOver on mobile. 60 | 61 | Many people use multiple screen readers, instead of relying on just one. For this reason (and because our philosophy is that [we must support all users, no matter their device, browser, or network condition](../practices/graded-browser-support.md)), we don't target specific Assistive Technology packages. 62 | 63 | ## Other accessibility tools 64 | 65 | ### Automated accessibility testing tools in the browser 66 | 67 | - Squizlabs have an [HMTML_Codesniffer bookmarklet](https://squizlabs.github.io/HTML_CodeSniffer/) for quick tests. 68 | - The Axe engine comes as a [browser extension](https://www.deque.com/axe/browser-extensions/) for Chrome, Firefox, and Edge, and as an [NPM module](https://github.com/dequelabs/axe-core) that you can integrate with your build, like Pa11y. 69 | - WebAim's [WAVE extension](https://wave.webaim.org/extension/) for Chrome and Firefox evaluates accessibility in place on the page. 70 | - The [ARC Toolkit](https://www.tpgi.com/arc-platform/arc-toolkit/) by TPGi is a useful extension for Chrome that (among other things) can detect semantic/structural issues, and problematic use of ARIA. 71 | 72 | ### Tools for manually analysing web pages 73 | 74 | In addition to Microsoft's Accessibility Insights tool, here are some other things we like: 75 | 76 | - Check colour contrast conformance with WebAim's [Colour Contrast Checker](https://webaim.org/resources/contrastchecker/) or TPGi's [Colour Contrast Analyser](https://www.tpgi.com/color-contrast-checker/) tool (for Mac and Windows). 77 | - The [Landmarks browser extension](http://matatk.agrip.org.uk/landmarks/) (for Firefox, Chrome and Opera) enables navigation of WAI-ARIA landmarks, via the keyboard or a pop-up menu. 78 | 79 | ### Tools for audio and video media accessibility 80 | 81 | - An extensive guide to [making audio and video media accessible](https://www.w3.org/WAI/media/av/) from the W3C. 82 | 83 | - The Trace Center’s [Photosensitive Epilepsy Analysis Tool (PEAT)](https://trace.umd.edu/peat/) is a downloadable resource that can identify seizure risks in web content and software. PEAT analyses visual media to detect patterns, flashing lights, and rapid color changes. 84 | 85 | ## Simulators 86 | 87 | Disability simulators are apps, extensions, or experiments that imitate the experience of being disabled for non-disabled people. They're designed to increase empathy and awareness of the issues facing disabled people. 88 | 89 | It's very important that you understand the limitations of disability simulators. No browser extension could ever give you an appreciation of what it's like to navigate the world as a disabled person. No blindfold game can teach you what it's like to be systematically discriminated against in virtually every aspect of your daily life. You can just switch the simulator off - a 90 | disabled person doesn't have that option. 91 | 92 | If used carelessly, disability simulators can also have the opposite effect of what's intended. Instead of giving non-disabled people empathy with those who experience disability in a particular context, they can elicit sympathy or pity reactions. Pity reactions lead to responses like "that's terrible", and not "how can we help?". As web professionals who care about the experiences of all of our users, we need to make sure our response to any disability simulators is "how can we help?". The [June 2017 issue of Braille Monitor](https://www.nfb.org/images/nfb/publications/bm/bm17/bm1706/bm170602.htm) discusses the research on disability simulation, its limitations, and how it can be improved. 93 | 94 | With this caveat in mind, here are some disability simulators that _may_ help you or your team understand _some_ of the ways in which people with some disabilities _may_ perceive your web pages. 95 | 96 | - [Funkify](http://www.funkify.org/) is an extension for Chrome that helps you experience the web and interfaces through the eyes of users with different abilities and disabilities. 97 | - [Empathy prompts](https://empathyprompts.net/) are flashcards with things to consider when making things for others to use. 98 | -------------------------------------------------------------------------------- /accessibility/03-accessibility-in-emails.md: -------------------------------------------------------------------------------- 1 | # Accessibility in emails 2 | 3 | Accessibility in emails can be summarised with 3 key points: 4 | 5 | 1. Accessible emails allow you to reach a wider audience. 6 | 1. Writing and visual design are key components of an accessible email campaign, so ensure that UX and content folk are involved in all discussions. 7 | 1. Email templates can be made immediately more accessible with a few simple coding techniques. 8 | 9 | Creating accessible emails is not fundamentally different from creating accessible websites. 10 | 11 | Here are the few differing constraints and techniques that should be considered. 12 | 13 | ## Layout 14 | 15 | Rich visual emails typically use tables for layout. This is because email clients use old and conservative browser engines that do not cope well nor consistently with CSS-based layouts. 16 | 17 | - Using ARIA to set `role="presentation"` on layout tables will help prevent them being seen as data tables by screen readers, and allow screen reader users to read the email contents easily. 18 | 19 | ## Specify a language 20 | 21 | Emails, even if sent in English, can be read out loud by browsers and operating systems using other languages. 22 | 23 | - Setting the language of the email on the root element will allow assistive technology to use the appropriate language profile. 24 | 25 | ## Use logical source order 26 | 27 | Screenreaders will rely on the logical source order of the HTML when they read out content. 28 | 29 | - Use the logical source order for the language you are writing in. 30 | - For most western languages, English included, this is left to right and top to bottom. 31 | - This includes the table cells and rows used for email layout. 32 | 33 | ## Alternative text 34 | 35 | Marketing emails tend to make heavy use of images, so it is important to ensure alt text is used well. 36 | 37 | - Alt text should be used as it would be on a web site. 38 | - If the image conveys meaning, add an alt description. 39 | - If the image is purely presentational, add an empty alt attribute (`alt=""`) to allow the screenreader to skip it. 40 | - If the image is an image of text, the alt attribute must contain that same text. 41 | - Never leave an image without an alt attribute as the assistive tech will read out the filename instead. If you're sure the image doesn't need alt text, use an empty alt attribute (`alt=""`). 42 | - Do not use alt text to prompt the user to enable images in their email client. 43 | 44 | ## Fonts 45 | 46 | Before the age of webfonts, browser content was restricted to a short list of ~10 “web-safe” fonts, or text in images. HTML emails are largely still subject to this restriction. While many email clients will allow an embedded webfont, the biggest one – GMail – does not. Also a webfont is another embedded resource in the email so using a webfont forces every user (including those on mobile) to download the custom font just to read a short email. 47 | 48 | TL;DR: use Courier for monospace, Times or Georgia for serif, and Arial/Helvetica for sans-serif, and **always** specify the default fallback at the end of the font stack. 49 | 50 | ## Use semantic content 51 | 52 | Semantic HTML helps screenreaders to read out content, and allows the email to be visually interpreted even if CSS is not available. 53 | 54 | - Pre-HTML5 elements `

` and `

`, `

`, are likely to work in all clients. 55 | 56 | ## Avoid HTML5 elements 57 | 58 | Any HTML elements that appeared in the HTML5 specification may be stripped by more conservative email clients. 59 | 60 | - Avoid using HTML5 elements, such as `
`, `