How do I format my posts using Markdown or HTML?

When posting on Software Quality Assurance & Testing Stack Exchange, you can use the visual editor (for questions and answers, but not comments), Markdown, and some HTML. If you're new to Markdown, you may want to visit the official Markdown syntax reference page.

Here are some tips for common formatting scenarios; more details are available on our advanced editing help page.

Code Blocks

Indent four spaces to create an escaped <pre> <code> block:

    printf("%d\n", 42);  /* what was the
                        question again? */

The text will be wrapped in tags, and displayed in a monospaced font. The first four spaces will be stripped off, but all other whitespace will be preserved. You can select a block of code and press ctrl K to automatically add four spaces to the beginning of every selected line.

Markdown and HTML are ignored within a code block:

    <blink>
      You would hate this if it weren't
      wrapped in a code block.
    </blink>

Inline Code

Use backticks (in the upper left corner of most keyboards) to create an inline <code> span:

You can use a `<div>`for this with `display: inline-block;` set.

This will be displayed as:

You can use a <div for this with <display: inline-block; set.

Like code blocks, code spans will be displayed in a monospaced font. Markdown and HTML will not work within them. Note that, unlike code blocks, code spans require you to manually escape any HTML within them.

Syntax highlighting for code

Code blocks can be highlighted using Google Prettify. In many cases, the syntax highlighting language will be inferred from the question's tags.

To manually specify the language of a code block, insert an HTML comment like this before the block:

<!-- language: lang-js -->

    setTimeout(function () { alert("JavaScript"); }, 1000);
    

You can use either one of the supported prettify language codes, like lang-cpp or lang-sql, or you can specify a tag, and the syntax highlighting language associated with this tag will be used:

<!-- language: c# -->

    public static bool IsAwesome { get { return true; } }
    

To specify a syntax highlighting language to be used not only for the next, but for all following code blocks, use

<!-- language-all: lang-html -->

To specify that you don't want any syntax highlighting for a code block, use

<!-- language-all: lang-none -->

Linebreaks

End a line with two spaces to add a <br/> linebreak:

How do I love thee?  
Let me count the ways

New paragraphs only occur when there is a blank line. A single carriage does not create a new paragraph.

Italics and Bold

*This is italicized*, and so is _this_.
**This is bold**, and so is __this__.
Use ***italics and bold together*** if you ___have to___.

Links

There are three ways to write links. Each is easier to read than the last:

Here's an inline link to `[Google](http://www.google.com/)`.
Here's a reference-style link to `[Google][1]`.
Here's a very readable link to `[Yahoo!][yahoo]`.

  [1]: http://www.google.com/
  [yahoo]: http://www.yahoo.com/

The link definitions can appear anywhere in the document -- before or after the place where you use them. The link definition names [1] and [yahoo] can be any unique string, and are case-insensitive; [yahoo] is the same as [YAHOO].

Advanced Links

Links can have a title attribute, which will show up on hover. Title attributes can also be added; they are helpful if the link itself is not descriptive enough to tell users where they're going.

Here's a `[poorly-named link](http://www.google.com/ "Google")`.
Never write "`[click here][^2]`".
Visit `[us][web]`.

  `[^2]:` http://www.w3.org/QA/Tips/noClickHere
        (Advice against the phrase "click here")
  `[web]:` http://programmers.stackexchange.com/ "Programmers Stack Exchange"

You can also use standard HTML hyperlink syntax.

<a href="http://example.com" title="example">example</a>

Simple lists

A bulleted <ul> list:

- Use a minus sign for a bullet
+ Or plus sign
* Or an asterisk

A numbered <ol> list:

1. Numbered lists are easy
2. Markdown keeps track of the numbers for you
7. So this will be item 3.

A double-spaced list:

- This list gets wrapped in `<p>` tags

- So there will be extra space between items

Simple blockquotes

Add a > to the beginning of any line to create a <blockquote>.

> The syntax is based on the way email programs
> usually do quotations. You don't need to hard-wrap
> the paragraphs in your blockquotes, but it looks much nicer if you do.  Depends how lazy you feel.

Tags

To talk about a tag on this site, , use

See the many questions tagged [tag:elephants] to learn more.

The tag will automatically be linked to the corresponding tag info page.