MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla
Your Search Results

    View source

    The View Source option in the Tools menu lets you look at the HTML or XML for the document you're viewing. This article provides useful information about this feature.

    Note: This article covers the new implementation of the View Source feature implemented in Firefox 11, which offers new features over older versions of Firefox.

    Features offered by View Source

    Syntax highlighting
    The View Source window uses the same HTML5 parser Firefox uses when processing content in order to offer accurate syntax highlighting of the markup.
    Error reporting
    The View Source window highlights parsing errors in red; hovering your mouse over errors displays a tooltip explaining the error.

    Limitations of View Source

    There are limitations to what View Source does for you that you need to be aware of.

    Error reporter ≠ validator

    The View Source window only reports parsing errors, not HTML validity errors. For example, putting a <div> element as a child of a <ul> element isn't a parse error, but it is not valid HTML. Therefore, this error will not be flagged in the View Source window. If you want to check that HTML is valid, you should use an HTML validator, such as the one offered by W3C.

    Not all parse errors are reported

    Even though all the reported errors are parse errors according to the HTML specification, not all parse errors are reported by View Source. Among the errors that don't get reported:

    • Bytes that are illegal according to the document's encoding aren't marked as errors.
    • Forbidden characters aren't reported as errors.
    • Errors related to the end-of-file aren't reported.
    • Tree builder errors relating to text (as opposed to tags, comments, or doctypes) aren't reported.
    • Parse errors related to xmlns attributes aren't reported.

    XML syntax highlighting

    The View Source window uses the HTML tokenizer when highlighting XML source. While the tokenizer has support for processing instructions when highlighting XML source, that's the only XML-specific capability provided. Because of this, doctypes that have an internal subset are not highlighted correctly, and entity references to custom entities are also not highlighted correctly.

    This mishighlighting can be seen by viewing the source of Firefox chrome files (such as XUL documents). However, this shouldn't be a problem in practice when viewing typical XML files.

    See also

    Document Tags and Contributors

    Contributors to this page: Hsivonen, Sheppy, yyss
    Last updated by: yyss,