HTML formatting
Stay organized with collections
Save and categorize content based on your preferences.
Line length
Break lines at 80 characters except in the following cases:
Break code snippets (in <pre>
blocks) at 80 characters:
- Older files might use different line lengths. If you're making small changes to a file that
has a consistent line length other than 80 characters, then make your changes conform to that
file's line length rather than reformatting the whole file.
- When adding line breaks, make sure that you don't change the meaning of the code! If you're
not familiar with the programming language, ask for help from someone who is. But sometimes you
just can't avoid a long line.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-15 UTC.
[null,null,["Last updated 2024-10-15 UTC."],[[["\u003cp\u003eAdhere to Google's HTML/CSS Style Guide, ensuring optional elements are included and utilizing spaces for indentation instead of tabs.\u003c/p\u003e\n"],["\u003cp\u003eMaintain consistent indentation with two spaces per level, employ lowercase for elements and attributes, and avoid trailing spaces unless necessary for Markdown.\u003c/p\u003e\n"],["\u003cp\u003eObserve an 80-character line length limit, with exceptions for meta elements, long URLs, and specific legacy file formatting.\u003c/p\u003e\n"],["\u003cp\u003eBreak code snippets within \u003ccode\u003e<pre>\u003c/code\u003e blocks at 80 characters while ensuring the code's meaning remains intact and considering exceptions for existing file consistency.\u003c/p\u003e\n"]]],["Adhere to Google's HTML/CSS Style Guide, but include optional elements. Use spaces, not tabs, for indentation, with two spaces per level. Employ lowercase for elements and attributes, and avoid trailing spaces. Limit line length to 80 characters, except for `meta` elements, URLs, or when maintaining existing file formatting. When adding line breaks, ensure they don't alter the code's meaning and long URLs should be on their own line.\n"],null,["# HTML formatting\n\nFollow Google's [HTML/CSS\nStyle Guide](https://google.github.io/styleguide/htmlcssguide.html). Exception: don't leave out optional elements.\n\nIn particular, following are some basic guidelines from that style guide,\nwhich generally apply to other documentation source files, too (such as YAML and Markdown):\n\n- **Don't use tabs** to indent text; use spaces only. Different text editors interpret tabs differently, and some Markdown features expect spaces and not tabs.\n- **Indent by two spaces** per indentation level.\n- **Use all-lowercase** for elements and attributes.\n- **Don't leave trailing spaces** at the end of a line (except as needed for Markdown).\n\nLine length\n-----------\n\nBreak lines at 80 characters except in the following cases:\n\n- Information in a `meta` element at the beginning of a file must be on a single line, so those lines can be as long as needed.\n- If a URL in a link has a line break, the link won't work. If a URL is longer than 80 characters (quite common), you're stuck with it. In that case, put the URL on its own line with the `href` attribute to make it easier to review the text before and after, as the following example shows: \n\n```\nYou can find more information in\n\u003ca href=\"https://example.com/long-url/johan-gambolputty-de-von-ausfern-…-von-hautkopf-of-ulm.html\"\n\u003ehis biography.\u003c/a\u003e\n```\n\nBreak code snippets (in `\u003cpre\u003e` blocks) at 80 characters:\n\n- Older files might use different line lengths. If you're making small changes to a file that has a consistent line length other than 80 characters, then make your changes conform to that file's line length rather than reformatting the whole file.\n- When adding line breaks, make sure that you don't change the meaning of the code! If you're not familiar with the programming language, ask for help from someone who is. But sometimes you just can't avoid a long line."]]