Writer's guide

In an effort to display documentation in an organized, standardized and easy-to-read manner, the Mozilla Developer Network style guide describes how text should be organized, spelled, formatted, and so on. These are guidelines rather than strict rules. We are more interested in content than formatting, so don't feel obligated to learn the style guide before contributing. Do not be upset or surprised, however, if an industrious volunteer later edits your work to conform to this guide.

The language aspects of this guide apply primarily to English-language documentation. Other languages may have (and are welcome to create) their own style guides.

For style standards that apply to non-technical writing, refer to the One Mozilla style guide.

Basics

Page names

Page names are used in search results and also used to structure the page hierarchy in the breadcrumb list at the top of the page. The page name (which is displayed at the top of the page and in the search results) can be different from the page "slug" (which is used to build the page URL).

Page and heading capitalization

Page names and section headings should use sentence-style capitalization (only capitalize the first word and proper nouns) rather than headline-style capitalization:

  • Correct: "A new method for creating JavaScript rollovers"
  • Incorrect: "A New Method for Creating JavaScript Rollovers"
The capitalization rules for page names apply to new pages. Many pages in this wiki don't conform to these rules. You can fix these exceptions as you are editing pages for other reasons but please don't edit a page for the sole purpose of fixing the page name's capitalization.

Unique page names

Wherever possible, pages should have a unique title. If the page topic is a common word like "Optimization", use an additional word that provides context, for example "Optimizing lists" or "CSS Optimization". If there are two or more pages which have the same "natural" title, a disambiguation page should be created.

Multi-page articles

If the content you are adding to the wiki requires multiple pages, use the following page naming method. This enables the wiki to build the breadcrumb list at the top of the page correctly.

If you don't use the pathname-like hierarchy depicted here, your articles will all be located at the top of the hierarchy instead of nested.

Sections, paragraphs, and newlines

Use heading levels in decreasing order: <h2> then <h3> then <h4>, without skipping levels. H2 is the highest level allowed because H1 is reserved for the page title. If you need more than three or four levels of headers you should consider breaking up the article into several smaller articles which are linked manually.

The enter (or return) key on your keyboard starts a new paragraph. To insert a newline without a space, hold down the shift key while pressing enter.

Text formatting and styles

Use the "Formatting Styles" drop-down list to apply predefined styles to selected content.

Note: The "Note" style is used to call out important notes, like this one.
Warning: Similarly, the "Warning" style creates warning boxes like this.

Code formatting

Tabs and line breaks

Use two spaces per tab in all code samples. Code should be indented cleanly. For example:

if (condition) {
  /* handle the condition */
} else {
  /* handle the "else" case */
} 

Long lines shouldn't be allowed to stretch off horizontally to the extent that they require horizontal scrolling to read. Instead, break at natural breaking points. Some examples follow:

if (class.CONDITION || class.OTHER_CONDITION || class.SOME_OTHER_CONDITION
       || class.YET_ANOTHER_CONDITION ) {
  /* something */
}

var toolkitProfileService = Components.classes["@mozilla.org/toolkit/profile-service;1"]
                           .createInstance(Components.interfaces.nsIToolkitProfileService);

Formatting

Use the "Code" button (labelled with two angle brackets "<>") to apply inline code-style formatting to function names, variable names, and method names. For example, "the frenchText() function".

Method names should be followed by a pair of parentheses: doSomethingUseful().

Syntax highlighting

Entire lines (or multiple lines) of code should be formatted via syntax highlighting. Select the text, then select the appropriate language from the "Syntax Highlighter" drop-down list. The following example shows text with JavaScript formatting:

for (var i = 0, j = 9; i <= 9; i++, j--)
  document.writeln("a[" + i + "][" + j + "]= " + a[i][j]);

If no appropriate transformation is available, use the pre tag.

x = 42;

Formatting HTML Elements

Element names
Use the HTMLElement template, (e.g., <title>), which creates a link to the page for that element. If you don't want to create a link, enclose the name in angle brackets and use "Code (inline)" style (e.g., <title>).
Attribute names
Use bold face.
Attribute definitions
Use the htmlattrdef template (e.g., type) for the definition term, so that it can be linked to from other pages. (Use the htmlattrxref template (e.g., attr) to reference attribute definitions.)
Attribute values
Use "Code (inline)" style, and do not use quotation marks around strings, unless needed by the syntax of a code sample. E.g.: When the type attribute of an <input> element is set to email or tel ...
Labeling attributes
Use labels like HTML5 thoughtfully. For example, use them next to the bold attribute name but not for every occurrence in your body text.

Force ignore of wiki markup

If you need a particular piece of wiki markup to be ignored by the parser, simply use the "plain" CSS class, like this:

<span class="plain">'''this wiki markup will not be interpreted'''</span>

'''this wiki markup will not be interpreted'''

Latin abbreviations

In notes and parentheses

  • Common Latin abbreviations (etc., i.e., e.g.) may be used in parenthetical expressions and in notes. Use periods in these abbreviations.
    • Correct: Web browsers (e.g. Firefox) can be used ...
    • Incorrect: Web browsers e.g. Firefox can be used ...
    • Incorrect: Web browsers, e.g. Firefox, can be used ...
    • Incorrect: Web browsers, (eg: Firefox) can be used ...

In running text

  • In regular text (i.e. text outside of notes or parentheses), use the English equivalent of the abbreviation.
    • Correct: ... web browsers, and so on.
    • Incorrect: ... web browsers, etc.
    • Correct: Web browsers such as Firefox can be used ...
    • Incorrect: Web browsers e.g. Firefox can be used ...

Meanings and English equivalents of Latin abbreviations

Abbrev Latin English
cf. confer compare
e.g. exempli gratia for example
et al. et alii and others
etc. et cetera and so forth, and so on
i.e. id est that is, in other words
N.B. nota bene note well
P.S. post scriptum postscript

N.B. Be careful not to confuse "e.g." with "i.e."

Acronyms and abbreviations

Capitalization and periods

Use full capitals and delete periods in all acronyms and abbreviations, including organizations such as "US" and "UN".

  • Correct: XUL
  • Incorrect: X.U.L.; Xul

Expansion

On the first mention of a term on a page, expand acronyms likely to be unfamiliar to users. When in doubt, expand it, or, better, link it to the article describing the technology.

  • Correct: "XUL (XML User Interface Language) is Mozilla's XML-based language..."
  • Incorrect: "XUL is Mozilla's XML-based language..."

Plurals of acronyms and abbreviations

For plurals of acronyms or abbreviations, add s.

  • Correct: CD-ROMs
  • Incorrect: CD-ROM's

Contractions

Use contractions (e.g. "don't", "can't", "shouldn't") if you prefer.

Pluralization

Use English-style plurals, not the Latin- or Greek-influenced forms.

  • Correct: syllabuses, octopuses
  • Incorrect: syllabi, octopi

Hyphenation

Hyphenate compounds when the last letter of the prefix is a vowel and is the same as the first letter of the root.

  • Correct: email, re-elect, co-op
  • Incorrect: e-mail, reelect, coop

Numbers and numerals

Dates

For dates (not including dates in code samples) use the format "January 1, 1990".

  • Correct: February 24, 2006
  • Incorrect: February 24th, 2006; 24 February, 2006; 24/02/2006

Alternately, you can use the YYYY/MM/DD format.

  • Correct: 2006/02/24
  • Incorrect: 02/24/2006; 24/02/2006; 02/24/06

Decades

For decades, use the format "1990s".

  • Correct: 1990s
  • Incorrect: 1990's

Plurals of numerals

For plurals of numerals add "s".

  • Correct: 486s
  • Incorrect: 486's

Commas

In running text, use commas only in five-digit and larger numbers.

  • Correct: 4000; 54,000
  • Incorrect: 4,000; 54000

Punctuation

Serial comma

Use the serial comma. The serial (also known as "Oxford") comma is the comma that appears before the conjunction in a series of three or more items.

  • Correct: I will travel on trains, planes, and automobiles.
  • Incorrect: I will travel on trains, planes and automobiles.

Spelling

For words with variant spellings, always use the first entry at Answers.com. Do not use variant spellings.

  • Correct: localize, honor
  • Incorrect: localise, honour

Terminology

Obsolete vs. deprecated

It's important to be clear on the difference between the terms obsolete and deprecated. On MDN:

  • Deprecated refers to a technology or API which is no longer recommended for use; typically, these are planned for eventual removal from the browser, although in reality, some APIs remain deprecated for many years. Regardless, you should avoid using deprecated APIs.
  • Obsolete refers to a technology or API which has been removed from the browser and no longer works. Most technologies go through a period of being deprecated before becoming obsolete and being removed.

HTML elements

Use "elements" to refer to HTML and XML elements, rather than "tags". In addition, they should almost always be wrapped in "<>", and should be in the <code> style. Also, at least the first time you reference a given element in a section should use the HTMLElement macro, to create a link to the documentation for the element (unless you're writing within that element's reference document page).

  • Correct: the <span> element
  • Incorrect: the span tag

User interface actions

In task sequences, describe user interface actions using the imperative mood. Identify the user interface element by its label and type.

  • Correct: Click the Edit button.
  • Incorrect: Click Edit.

Voice

While the active voice is generally preferred, the passive voice is also acceptable.

Wiki markup and usage

To automatically create a link to a Bugzilla bug, use this template:

{{Bug(322603)}}

This results in:

bug 322603

For WebKit bugs, you can use this template:

{{Webkitbug("322603")}}

This results in:

WebKit bug 322603

Tags

Tags provide meta information about a page and / or indicate that a page needs work or is deprecated. Every page in the wiki should be tagged. To add and edit tags for a page, edit the Tags text field at the bottom of the page. Tags will autocomplete as you type. Each article may have as many tags as appropriate. For example, an article about using JavaScript in AJAX programming might have both "JavaScript" and "AJAX" as tags.

Tagging pages that need work

Some of the most common editing tags we use are:

  • NeedsMarkupWork: the formatting is not standard or not consistent with other pages.
  • NeedsExample: needs one or more illustrative code examples of the item documented.
  • NeedsContent: the item is incomplete and needs to be filled out.
  • NeedsJSVersion: needs information about the version of JavaScript and EcmaScript this item first appears in.
  • NeedsBrowserCompatibility: needs a browser compatibility table or needs the table filled out.
  • MakeBrowserAgnostic: the article is written with a focus on Gecko, when it is actually about a standard function or feature, which should be rewritten to be generic.

Tagging obsolete pages

Use the following tags for pages that are not current:

  • Junk: Use for spam, pages created by mistake, or content that is so bad that it should be deleted. Pages with this tag are deleted from time to time.
  • Obsolete: Use for content that is technically superceded, but still valid in context. For example an HTML element that is obsolete in HTML5 is still valid in HTML 4.01. You can also use the

    Obsolete
    This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

    template to put a prominent banner on the topic.
  • Archive: Use for content that is technically superceded and no longer useful. If possible, add a note to the topic referring readers to a more current topic. For example, a page that describes how to use the Mozilla CVS repository should refer readers to a current topic on using Mercurial repos. (If no corresponding current topic exists, use the NeedsUpdate tag, and add an explanation on the Talk page.) Pages with the Archive tag may eventually be moved into an archive sub-tree and/or hidden in search results.

Landing pages

Landing pages are pages at the root of a topic area of the site, such as the main CSS or HTML pages. They have a standard format that consists of three areas:

  1. A brief (typically one paragraph) overview of what the technology is and what it's used for. See Writing a landing page overview for tips.
  2. A two-column list of links with appropriate headings. See Creating a page link list for guidelines.
  3. An optional "Browser compatibility" section at the bottom of the page.

The link list section of an MDN landing page consists of two columns. These are created using the following HTML:

<div class="row topicpage-table">
  <div class="section">
    ... left column contents ...
  </div>
  <div class="section">
    ... right column contents ...
  </div>
</div>

The left-hand column should be a list of articles, with an <h2> header at the top of the left column explaining that it's a list of articles about the topic (for example "Documentation and tutorials about foo"); this header should use the CSS class "Documentation". Below that is a <dl> list of articles, with each article's link in a <dt> block and a brief one-or-two sentence summary of the article in the corresponding <dd> block.

The right-hand column should contain one or more of the following sections, in order:

SEO summary

The SEO summary is a very short summary of the page. It will be reported as a summary of the article to robots crawling the site, and will then appear in search results for the page. It is also used by macros that automate the construction of landing pages inside MDN itself.

By default, the first pagragraph of the page is used as the SEO summary. However you can override this behavior by marking a section with the "SEO summary" style in the WYSIWYG editor.

Getting help from the community
This should provide information on IRC channels and mailing lists available about the topic. The heading should use the class "Community".
Tools
A list of tools the user can look at to help with the use of the technology described in this section of MDN. The heading should use the class "Tools".
Related topics
A list of links to landing pages for other, related, technologies of relevance. The heading should use the class "Related_Topics".

Using, inserting images

It's sometimes helpful to provide an image in an article you create or modify, especially if the article is very technical. To include an image:

  1. Attach the desired image file to the article (at the bottom of every article in edit mode)
  2. Create an image in the WYSIWYG editor
  3. In the WYSIWYG editor in the drop-down list listing attachments, select the newly created attachment which is your image
  4. Press OK.

Other References

Preferred style guides

If you have questions about usage and style not covered here, I recommend referring to the Economist style guide or, failing that, the Chicago Manual of Style. The Yahoo Style Guide covers many topics that are specific to writing on and about the Web (no longer accessible online).

Preferred dictionary

For questions of spelling, please refer to Answers.com. The spell-checker for this site uses American English. Please do not use variant spellings (e.g., use honor rather than honour).

We will be expanding the guide over time, so if you have specific questions that aren't covered in this document, please send them to the MDC mailing list or project lead so we know what should be added.

MDC-specific

Language, grammar, spelling

If you're interested in improving your writing and editing skills, you may find the following resources to be helpful.

Document Tags and Contributors

Last updated by: enderandpeter,