--- title: Настанови зі стилю slug: MDN/Guidelines/Настанови_зі_стилю tags: - MDN Meta - Style guide - Настанови зі стилю - Путівник translation_of: MDN/Guidelines/Writing_style_guide ---
Щоб зробити викладення документації на MDN Web Docs однорідним, виразним та легкочитним, в цих настановах зазначено, як слід писати, форматувати й упорядковувати текст. Втім, це радше посібник, аніж перелік суворих вимог. Звісно, нас більше цікавить вміст, аніж форма викладення, тож не переймайтесь надмірно докладним вивченням настанов зі стилю. Але й не дивуйтесь, якщо хтось із сумлінних добровольців згодом виправить ваш доробок задля дотримання наведених тут правил.
Мовознавчі настанови цього посібника стосуються здебільшого англійської мови. Для інших мов можна й варто створювати окремі стильові посібники. Їх слід оприлюднювати як підстатті основної сторінки перекладацької команди.
Стандарти стилю, що стосуються вмісту на інших (окрім MDN) сайтах, наведено у Єдиному посібнику зі стилю Mozilla.
Найкраще місце для початку в будь-якому великому керівництві - це певні базові текстові стандарти, які допомагають дотримуватись сумісності документації. Наступні розділи описуються деякі із цих основ, які допоможуть вам.
Назви сторінок використовуються в результатах пошуку, а також для структурування ієрархії сторінок у списку "хлібних крихт" зверху сторінки. Назви сторінок (які відображаються зверху сторінки, а також у результатах пошуку) можуть відрізнятись від "slug" (унікальний ідентифікатор) соторінки, яка є частиною URL адреси після "<locale>/docs/".
Заголовки сторінок та заголовки розділів мають починатись з великої літери (використовується лише для першого слова в реченні та власних імен), але не кожне слово:
У нас є багато старих сторінок, які було написано до встановлення цього правила. За бажанням ви можете оновити їх, аби вони стали більш читабильними. Поступово ми доберемось до їх редагування.
Унікальний ідентифікатор має бути коротким; коли створюєте новий рівень ієрархії, компонент нового рівня у вигляді "slug" ідентифікатора має складатись із одного-двох слів.
Заголовки сторінок, з іншої сторони, можуть бути такими довгими на скільки це потрібно і мають описувати суть статті.
Коли вам потрібно додати якісь статті до певної теми чи області обговорення, ви можете зробити це створивши цільову сторінку, після цього додавайте підсторінки для кожної окремої статті. Цільова сторінка має описуватись за допомогою одного або двох абзаців, які розкривають тему чи технологію, потім відобразіть список підсторінок з поясненням до кожної з них. Ви можете автоматизувати вставку сторінок в список, використовуючи макроси, які ми створили.
For example, consider the JavaScript guide, which is structured as follows:
Try to avoid putting your article at the top of the hierarchy, which slows the site down and makes search and site navigation less effective.
When writing any document, it's important to know how much to say. If you ramble on too long, the article becomes tedious to read and nobody will use it. Getting the amount of coverage right is important for several reasons. Among those reasons: to ensure that the reader finds the information they truly need, and to provide enough quality material for search engines to adequately analyze and rank the article. We'll discuss the former (providing the information the reader may need) here. To learn a little about ensuring that pages are properly classified and ranked by search engines, see the article How to write for SEO on MDN.
The goal is to write pages that include all the information that readers may need without going on too long about it all. We have a few recommendations in this area.
Keep in mind that these are guidelines. Some of these tips may not apply in every case. Certainly keep your article's audience in mind. An article on advanced network techniques likely doesn't need to go into as much detail about basic networking concepts as the typical article on networking code, for instance.
Make sure the article's summary—that is, the opening paragraph or paragraphs before the first heading—provides enough information for the reader to understand if the article is likely to be covering what they're interested in reading about. In guide or tutorial content, the summary should let the reader know what topics will be covered and what they're already expected to know, if anything. It should mention the technology, technologies, and/or APIs that are being documented or discussed, with links to those, and it should offer hints as to the situations in which the article's contents might be useful.
This example of a summary is far too short. It leaves out too much information, such as what it means exactly to "stroke" text, where the text is drawn, and so forth.
CanvasRenderingContext2D.strokeText()
draws a string.
Here, we've updated the summary, but now it's far too long. Too much detail is included, and the text gets far too much into other methods and properties. Instead, the summary should focus on the strokeText()
method, and should refer to the appropriate guide where the other details are offered.
When called, the Canvas 2D API method CanvasRenderingContext2D.strokeText()
strokes the characters in the specified string beginning at the coordinates specified, using the current pen color. In the terminology of computer graphics, "stroking" text means to draw the outlines of the glyphs in the string without filling in the contents of each character with color.
The text is drawn using the context's current font as specified in the context's {{domxref("CanvasRenderingContext2D.font", "font")}} property.
The placement of the text relative to the specified coordinates are determined by the context's textAlign
, textBaseline
, and direction
properties. textAlign
controls the placement of the string relative to the X coordinate specified; if the value is "center"
, then the string is drawn starting at x - (stringWidth / 2)
, placing the specified X-coordinate in the middle of the string. If the value is "left"
, the string is drawn starting at the specified value of x
. And if textAlign
is "right"
, the text is drawn such that it ends at the specified X-coordinate.
(etc etc etc...)
You can, optionally, provide a fourth parameter that lets you specify a maximum width for the string, in pixels. If you provide this parameter, the text is compressed horizontally or scaled (or otherwise adjusted) to fit inside a space that wide when being drawn.
You can call the fillText()
method to draw a string's characters as filled with color instead of only drawing the outlines of the characters.
Here we see a much better overview for the strokeText()
method.
The {{domxref("CanvasRenderingContext2D")}} method strokeText()
, part of the Canvas 2D API, strokes—that is, draws the outlines of—the characters of a specified string, anchored at the position indicated by the given X and Y coordinates. The text is drawn using the context's current {{domxref("CanvasRenderingContext2D.font", "font")}}, and is justified and aligned according to the {{domxref("CanvasRenderingContext2D.textAlign", "textAlign")}}, {{domxref("CanvasRenderingContext2D.textBaseline", "textBaseline")}}, and {{domxref("CanvasRenderingContext2D.direction", "direction")}} properties.
For more details and further examples, see {{SectionOnPage("/uk/docs/Learn/JavaScript/Client-side_web_APIs/Drawing_graphics", "Text")}} in the Learning Area as well as our main article on the subject, Drawing text.
More pages should have examples than should not have them. The majority of pages most likely deserve multiple examples, in fact. It's important to ensure that you use examples to clarify what every parameter is used for, and to clarify any edge cases that may exist. You should also use examples to demonstrate solutions for common tasks, and you should use examples to demonstrate solutions to problems that may arise.
Each example should be preceded by text explaining what the example does and anything the reader should know before beginning to read or try out the example.
In addition, each piece of code should include an explanation of how it works. Keep in mind that it may make sense to break up a large piece of code into smaller portions so they can be described individually. The text following each piece of code should explain anything relevant, using an appropriate level of detail. If the code is very simple and doesn't really feature anything directly related to the API being documented, you may only give a quick summary of what it is and why it's there. If the code is intricate, uses the API being documented, or is technically creative, you should provide a more detailed explanation.
When using the live sample system, it's helpful to be aware that all of the {{HTMLElement("pre")}} blocks in the area that contains the sample are concatenated together before running the example, which lets you break any or all of the HTML, CSS, and JavaScript into multiple segments, each optionally with its own descriptions, headings, and so forth. This makes documenting code incredibly powerful and flexible.
If an article is "thin"—that is, too short—it may not be indexed properly (or at all) by search engines. As a rule of thumb, the article's body text should be at least 250-300 words. Don't artificially inflate a page that simply can't reasonably be made longer than that, but treat this guideline as a target to shoot for as a minimum when possible.
Use heading levels in decreasing order: {{HTMLElement("h2")}} then {{HTMLElement("h3")}} then {{HTMLElement("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 with a landing page, linking them together using the {{TemplateLink("Next")}}, {{TemplateLink("Previous")}}, and {{TemplateLink("PreviousNext")}} macros.
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.
Don't create single subsections — you don't subdivide a topic into one. It's either two subheadings or more or none at all.
Don't have bumping heads, which are headings followed immediately by headings. Aside from looking horrible, it's helpful to readers if every heading has at least a brief intro after it to introduce the subsections beneath.
Lists should be written in a similar format across all contributions. Correct procedures should include suitable punctuation and sentence structure regardless of the list format. However dependent on the type of list you are writing, you must adjust your format accordingly. Refer to the documentation below to understand the differences of each.
Bulleted lists should be used for grouping purposes to create concise but effective pieces of information. Each new piece of information must start with a '•' to signify a new piece. Bulleted lists must follow standard punctuation usage, pay attention to the use of full stops; they must be included at the end of each sentence just like standard writing practice.
An example of a correctly structured bulleted list:
In this example we should include:
Yet another condition, some further explanation.
Note how the format remains the same from bullet to bullet. Create a bullet point, state a condition that has relevence to your indented topic and add some pausing punctuation in order to follow up the condition with a concise explanation.
Instruction lists must follow suitable numbering and format. It is important to include these attributes as with instructions, being clear is a key priority. Create the list in a similar style to a bulleted list, however numbered or instruction lists can be extensive where necessary, meaning correct punctuation is vital as you will be forming complex sentences.
An example of a correctly structured numbered list:
In order for you to structure a correct numbered list you must:
1. Begin with creating an introductory heading to lead into the instructions. This way we can provide the user with context before beginning the instructions.
2. Start creating your instructions, listing your instructions with numbers. This is a standard format of a numbered list that is easily recognizable by the user. Your instructions may be quite extensive, so it is important to write effectively and use correct punctuation where necessary.
3. After you have finished your instructions, close off the numbered list with a brief explanation of the outcome upon completion.
This is an example of writing your closing explanation. We have created a short numbered list which provides instructive steps to produce a numbered list with the correct formatting.
Numbered lists are almost exclusive for instructive purposes, so before writing consider your approach based on the context of the information you are trying to relay.
Use the "Formatting Styles" drop-down list to apply predefined styles to selected content.
Unless specifically instructed to do so, do not use the HTML style
attribute to manually style content. If you can't do it using a predefined class, drop into {{IRCLink("mdn")}} and ask for help.
Note: This section deals with the styling/formatting of code as it appears on an MDN article. If you want guidelines on actually writing code examples, see our Code sample guidelines.
Use two spaces per tab in all code examples. Indent the code cleanly, with open-brace ("{") characters on the same line as the statement that opens the block. 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);
Use the "Code" button (labeled with two angle brackets "<>") to apply inline code-style formatting to function names, variable names, and method names (this uses the {{HTMLElement("code")}} element). For example, "the frenchText()
function".
Method names should be followed by a pair of parentheses: doSomethingUseful()
. The parentheses help differentiate methods from other code terms.
Entire lines (or multiple lines) of code should be formatted using syntax highlighting rather than the {{HTMLElement("code")}} element. Select the appropriate language from the language list button (the one with the two code blocks), as seen in the screenshot to the right. This will insert a preformatted code box with line numbers and syntax highlighting for the chosen language.
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 language is available, use ("No Highlight" in the language menu). This will result in code without syntax highlighting:
x = 42;
If you want to insert a syntax definition, you can choose the "Syntax Box" option from the "Styles" drop-down menu in the editor toolbar. This will give the syntax definition a special formatting distinguishing it from normal code.
There are a few use cases where a <pre> block does not refer to code and doesn't have syntax highlighting nor line numbers. In such cases you should add a <pre> without class. Those cases include things like tree structures:
root/ folder1/ file1 folder2/ file2 file3
To create preformatted content without syntax highlighting and line numbers click the "pre" button in the toolbar. Then start to type the text.
There are specific rules to follow when writing about HTML elements. These rules produce consistent descriptions of elements and their components. They also ensure correct linking to detailed documentation.
<title>
).<input>
element is set to email
or tel
...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 |
Always consider whether it's truly beneficial to use a Latin abbreviation. Some of these are used so rarely that many readers won't understand the meaning, and others are often confused with one another. And be sure that you use them correctly, if you choose to do so. For example, be careful not to confuse "e.g." with "i.e.", which is a common error.
Use full capitals and delete periods in all acronyms and abbreviations, including organizations such as "US" and "UN".
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 or glossary entry describing the technology.
For plurals of acronyms or abbreviations, add s. Don't use an apostrophe. Ever. Please.
The contraction "vs." is preferred.
Use standard English capitalization rules in body text, and capitalize "World Wide Web." It is acceptable to use lower case for "web" (used alone or as a modifier) and "internet;" this guideline is a change from a previous version of this guide, so you may find many instances of "Web" and "Internet" on MDN. Feel free to change these as you are making other changes, but editing an article just to change capitalization is not necessary.
Keyboard keys should use sentence-style capitalization, not all-caps capitalization. For example, "Enter" not "ENTER."
Our writing style tends to be casual, so you should feel free to use contractions (e.g., "don't", "can't", "shouldn't") if you prefer.
Use English-style plurals, not the Latin- or Greek-influenced forms.
Hyphenate compounds when the last letter of the prefix is a vowel and is the same as the first letter of the root.
It is a good idea to use gender-neutral language in any writing where gender is irrelevant to the subject matter, to make the text as inclusive as possible. So for example, if you are talking about the actions of a specific man, usage of he/his would be fine, but if the subject is a person of either gender, he/his isn't appropriate.
Let's take the following example:
A confirmation dialog appears, asking the user if he allows the Web page to make use of his Web cam.
A confirmation dialog appears, asking the user if she allows the Web page to make use of her Web cam.
Both versions are gender-specific. To fix this, use gender-neutral pronouns:
A confirmation dialog appears, asking the user if they allow the Web page to make use of their Web cam.
MDN allows the use of this very common syntax (which is controversial among usage authorities), to make up for the lack of a neutral gender in English. The use of the third-person plural as a gender neutral pronoun (that is, using "they," "them", "their," and "theirs") is an accepted practice, commonly known as "singular 'they.'"
You can use both genders:
A confirmation dialog appears, asking the user if he or she allows the web page to make use of his/her web cam.
making the users plural:
A confirmation dialog appears, asking the users if they allow the web page to make use of their web cams.
The best solution, of course, is to rewrite and eliminate the pronouns:
A confirmation dialog appears, requesting the user's permission for web cam access.
A confirmation dialog box appears, which asks the user for permission to use the web cam.
The last way of dealing with the problem is arguably better, as it is not only grammatically more correct but removes some of the complexity associated with dealing with genders across different languages that may have wildly varying gender rules. This solution can make translation easier for both readers and localizers.
For dates (not including dates in code samples) use the format "January 1, 1990".
Alternately, you can use the YYYY/MM/DD format.
For decades, use the format "1990s". Don't use an apostrophe.
For plurals of numerals add "s". Don't use an apostrophe.
In running text, use commas only in five-digit and larger numbers.
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.
This is in contrast to the One Mozilla style guide, which specifies that the serial comma is not to be used. MDN is an exception to this rule.
For words with variant spellings, always use their American English spelling. In general, use the first entry at Dictionary.com, unless that entry is listed as a variant spelling or as being primarily used in a non-American form of English; for example, if you look up "honour", you find the phrase "Chiefly British" followed by a link to the American standard form, "honor". Do not use variant spellings.
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 {{HTMLElement("code")}} style. When you reference a given element for the first time in a section, you should use the {{TemplateLink("HTMLElement")}} macro to create a link to the documentation for the element (unless you're writing within that element's reference document page).
The preferred term on MDN is parameters. Please avoid the term "arguments" for consistency if at all possible.
In task sequences, describe user interface actions using the imperative mood. Identify the user interface element by its label and type.
While the active voice is preferred, the passive voice is also acceptable, given the informal feel of our content. Try to be consistent, though.
Links are a large part of what makes a wiki a powerful learning and teaching tool. Below you'll find some basic information, but you can find a complete guide to creating and editing links on MDN in our editor guide.
We encourage you to create appropriate links among articles; they help improve navigation and discoverability of content. You can easily create links not only among pages on MDN (internal links) but also to pages outside MDN (external links).
There are two ways to create links: you explicitly create a link using the Link button in the editor's toolbar—or by pressing Ctrl+K (Cmd-K on the Mac)—or you can use MDN's powerful macro system to generate links automatically or based on an input value.
When deciding what text to use as a link, there are a few guidelines you can follow:
For security reasons, you should only create links that use the following schemes:
http://
https://
ftp://
mailto:
Others may or may not work, but are not supported and will probably be removed by editorial staff.
In particular, be sure not to use the about:
or chrome://
schemes, as they will not work. Similarly, the javascript:
scheme is blocked by most modern browsers, as is jar:
.
Tags provide meta information about a page and/or indicate that a page has specific improvements needed to its content. Every page in the wiki should have tags. You can find details on tagging in our How to properly tag pages guide.
The tagging interface lives at the bottom of a page while you're in edit mode, and looks something like this:
To add a tag, click in the edit box at the end of the tag list and type the tag name you wish to add. Tags will autocomplete as you type. Press enter (or return) to submit the new tag. Each article may have as many tags as needed. For example, an article about using JavaScript in AJAX programming might have both "JavaScript" and "AJAX" as tags.
To remove a tag, just click the little "X" icon in the tag.
In addition to using tags to track information about the documentation's quality and content, we also use them to mark articles as needing specific types of work.
Use the following tags for pages that are not current:
The SEO summary provides a short description of a 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 paragraph 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.
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:
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 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 (e.g., "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 column should contain one or more of the following sections, in order:
<<<finish this once we finalize the landing page standards>>>
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:
If you have questions about usage and style not covered here, we recommend referring to the Economist style guide or, failing that, the Chicago Manual of Style.
For questions of spelling, please refer to Dictionary.com. The spelling checker for this site uses American English. Please do not use variant spellings (e.g., use color rather than colour).
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.
If you're interested in improving your writing and editing skills, you may find the following resources to be helpful.