{"id":20290686,"url":"https://github.com/gocardless/html-style-guide","last_synced_at":"2026-03-08T13:37:01.618Z","repository":{"id":35726187,"uuid":"40004534","full_name":"gocardless/html-style-guide","owner":"gocardless","description":"How we write HTML at GoCardless","archived":false,"fork":false,"pushed_at":"2017-11-28T09:31:11.000Z","size":5,"stargazers_count":11,"open_issues_count":0,"forks_count":4,"subscribers_count":93,"default_branch":"master","last_synced_at":"2025-01-14T08:52:54.196Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gocardless.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-31T12:35:18.000Z","updated_at":"2020-04-08T13:15:42.000Z","dependencies_parsed_at":"2022-09-05T01:11:00.450Z","dependency_job_id":null,"html_url":"https://github.com/gocardless/html-style-guide","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocardless%2Fhtml-style-guide","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocardless%2Fhtml-style-guide/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocardless%2Fhtml-style-guide/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gocardless%2Fhtml-style-guide/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gocardless","download_url":"https://codeload.github.com/gocardless/html-style-guide/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241787488,"owners_count":20020099,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T15:08:43.368Z","updated_at":"2026-03-08T13:37:01.591Z","avatar_url":"https://github.com/gocardless.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"## GoCardless HTML style guide\n\nHave a look at how we write HTML at GoCardless - let us know if you've found the same rules effective, if you've used others that are better, or if there's anything missing entirely which you think it's worth having a rule for!\n\n### 1. Basic formatting\n\n#### a. We delimit attribute values using double-quotes\n\nGood:\n```html\n\u003cdiv class=\"much-class\"\u003e\n```\n\nNot so good:\n```html\n\u003cdiv class='very-attribute'\u003e\n```\n\n#### b. Each indentation is two spaces long\n\nGood: \n```html\n\u003cdiv class=\"parent\"\u003e\n··\u003cdiv class=\"parent__child\"\u003e\u003c/div\u003e\n\n··\u003cdiv class=\"parent__child parent__child--variant\"\u003e\n····\u003cspan\u003eCan I live?\u003c/span\u003e\n··\u003c/div\u003e\n\u003c/div\u003e\n```\n\nNot so good:\n```html\n\u003cdiv class=\"parent\"\u003e\n····\u003cdiv class=\"parent__child\"\u003e\u003c/div\u003e \u003c!-- Too much indentation --\u003e\n\n··\u003cdiv class=\"parent__child parent__child--variant\"\u003e\n··\u003cspan\u003eCan I live?\u003c/span\u003e \u003c!-- Not enough indentation --\u003e\n··\u003c/div\u003e\n\u003c/div\u003e\n```\n\n#### c. We don’t include a forward-slash on void elements\n\nGood:         \n```html\n\u003cbr\u003e\n```\n\nNot so good:\n```html\n\u003cbr/\u003e\n```\n\n### 2. Structure\n\nWe strive for easy-to-parse, tidy code and have found a few rules pretty great for keeping things readable and neat\n\n#### a. Some things can stay on one line\n\nGood: \n```html\n\u003cdiv\u003e\u003c/div\u003e\n```\n\nAlso good:\n```html\n\u003cdiv\u003eCan I live?\u003c/div\u003e\n```\n\nUse judgement as to when it stops being readable, or is nearing your maximum line length.\n\nFor example, this might be best:\n```html\n\u003cdiv\u003e\n··Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor\n\u003c/div\u003e\n```\n\n#### b. Nesting elements means visual nesting too \n\nGood:\n```html\n\u003cdiv\u003e\n··\u003ca\u003eFoo\u003c/a\u003e\n\u003c/div\u003e\n```\n\n#### c. Add space between elements for readability\n\nIt probably isn’t necessary between parent \u0026 child elements or multiple one-line elements:\n\neg\n```html\n\u003cul\u003e\n··\u003cli\u003e1\u003c/li\u003e \u003c!-- ^^^ No space between parent `ul` and child `li` --\u003e\n··\u003cli\u003e2\u003c/li\u003e \u003c!-- ^^^ No space between multiple one-line elements --\u003e\n\u003c/ul\u003e\n```\n\nThe parent/child rule would apply to single multi-line elements too:\n\neg\n```html\n\u003cdiv\u003e\n··\u003cspan\u003e \u003c!-- ^^^ No space between parent `div` and child `span` --\u003e\n····Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n··\u003c/span\u003e\n\u003c/div\u003e\n```\n\nBut might be better between same-level multi-line elements:\n\neg\n```html\n\u003cul\u003e\n··\u003cli\u003e\n····Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n··\u003c/li\u003e\n  \n··\u003cli\u003e \u003c!-- ^^^ Space between same-level multi-line elements --\u003e\n····Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n··\u003c/li\u003e\n\u003c/ul\u003e\n```\n\nAlso between groups of one-line elements: \n\neg:\n```html\n\u003cdiv\u003e\n··\u003cspan\u003eFoo\u003c/span\u003e\n··\u003cspan\u003eBar\u003c/span\u003e\n\n··\u003cspan\u003eFoo\u003c/span\u003e \u003c!-- ^^^ Space between groups of one-line elements --\u003e\n··\u003cspan\u003eBar\u003c/span\u003e\n\n··\u003cspan\u003e \u003c!-- ^^^ Space between groups of one-line elements --\u003e\n····Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n··\u003c/span\u003e\n\u003c/div\u003e\n```\n\nAnd finally between any combinations of one-line or multi-line elements (so basically bear in mind spacing as soon as you introduce a multi-line element):\n\neg:\n```html\n\u003cdiv\u003e\n··\u003cspan\u003eFoo\u003c/span\u003e\n\n··\u003cspan\u003e \u003c!-- ^^^ Space between one-line and multi-line --\u003e\n····Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod\n··\u003c/span\u003e\n\u003c/div\u003e\n```\n\n#### d. Try using line-breaks for multiple attributes, keeping the first attribute on the tag's opening line\n\nGood:\n```html\n\u003cdiv custom-attribute \nclass=\"something\" \nrole=\"something-else\"\u003e\u003c/div\u003e \n\u003c!-- The closing tag    ^^^    can stay on the same line for empty elements--\u003e\n\n\u003cdiv custom-attribute \nclass=\"something\" \nrole=\"something-else\"\u003e\n··Foo \u003c!-- Otherwise nest plz --\u003e\n\u003c/div\u003e \n```\n\n#### e. Use your judgement on all the above for when things become less readable\n\nMight be OK:\n```html\n\u003cinput required custom-attribute\u003e\n```\n\nMight not be OK:\n```html\n\u003ccustom-element class=\"foo\" custom-attribute=\"value-for-custom-attr\"\u003eBar\u003c/custom-element\u003e\n```\n\nMight be better:\n```html\n\u003ccustom-element class=\"foo\"\ncustom-attribute=\"value-for-custom-attr\"\u003e\n  Bar\n\u003c/custom-element\u003e\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgocardless%2Fhtml-style-guide","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgocardless%2Fhtml-style-guide","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgocardless%2Fhtml-style-guide/lists"}