# Attribute “xmlns:m” not allowed here.

> Canonical HTML version: https://rocketvalidator.com/html-validation/attribute-xmlns-m-not-allowed-here
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

The HTML5 specification strictly limits which attributes are valid on the `<html>` element—and on elements in general. Standard global attributes like `lang`, `dir`, `class`, and `id` are permitted, and in XHTML serialization the plain `xmlns` attribute is allowed to declare the default XHTML namespace. However, prefixed namespace declarations like `xmlns:m`, `xmlns:o`, `xmlns:v`, or `xmlns:w` are XML constructs that have no meaning in the HTML5 (text/html) parsing model.

These prefixed namespace attributes most often appear when content is generated by or copied from Microsoft Office products (Word, Excel, PowerPoint). Office uses custom XML namespaces such as `xmlns:m` for Office MathML (`http://schemas.microsoft.com/office/2004/12/omml`) and `xmlns:o` for Office-specific markup. When this markup is saved as HTML or pasted into a web page, these declarations come along and trigger validation errors.

## Why This Is a Problem

- **Standards compliance:** The W3C HTML5 specification does not support custom XML namespace declarations in the `text/html` serialization. Validators will flag every such attribute.
- **No functional benefit:** HTML5 parsers ignore namespace prefixes entirely. The `xmlns:m` declaration does nothing in a browser rendering an HTML5 page, so it is dead code.
- **Content bloat:** Office-generated HTML often includes many unnecessary namespace declarations, inline styles, and proprietary elements that bloat the document and make it harder to maintain.
- **Accessibility and interoperability:** Clean, valid HTML is easier for assistive technologies, search engines, and other user agents to process reliably.

## How to Fix It

1. **Remove the custom namespace attribute** from the `<html>` element (or whichever element it appears on).
2. **Remove any elements or attributes** that depend on that namespace prefix (e.g., `<m:oMath>`, `<o:p>`), since they are not valid HTML5 elements.
3. **Replace with HTML5-native equivalents** where possible. For example, MathML is natively supported in HTML5 without any namespace declaration—you can use `<math>` elements directly.
4. **If you truly need XML namespaces**, serve your document as XHTML with the `application/xhtml+xml` content type instead of `text/html`.

## Examples

### Incorrect: Custom namespace on the `html` element

This triggers the "Attribute `xmlns:m` not allowed here" error:

```html
<!DOCTYPE html>
<html xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"
      xmlns:o="urn:schemas-microsoft-com:office:office"
      lang="en">
  <head>
    <title>Office Paste Example</title>
  </head>
  <body>
    <p>Some content with Office markup.</p>
  </body>
</html>
```

### Correct: Clean HTML5 without namespace declarations

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>Clean HTML5 Example</title>
  </head>
  <body>
    <p>Some content without Office markup.</p>
  </body>
</html>
```

### Correct: Using MathML natively in HTML5

If the `xmlns:m` namespace was being used for mathematical content, HTML5 supports MathML directly without any namespace declaration:

```html
<!DOCTYPE html>
<html lang="en">
  <head>
    <title>MathML in HTML5</title>
  </head>
  <body>
    <p>The quadratic formula:</p>
    <math>
      <mi>x</mi>
      <mo>=</mo>
      <mfrac>
        <mrow>
          <mo>-</mo>
          <mi>b</mi>
          <mo>±</mo>
          <msqrt>
            <mrow>
              <msup><mi>b</mi><mn>2</mn></msup>
              <mo>-</mo>
              <mn>4</mn><mi>a</mi><mi>c</mi>
            </mrow>
          </msqrt>
        </mrow>
        <mrow>
          <mn>2</mn><mi>a</mi>
        </mrow>
      </mfrac>
    </math>
  </body>
</html>
```

### Incorrect: Namespace attribute on a non-`html` element

The same error can appear on other elements too:

```html
<div xmlns:o="urn:schemas-microsoft-com:office:office">
  <p>Office content</p>
</div>
```

### Correct: Remove the namespace attribute

```html
<div>
  <p>Office content</p>
</div>
```

If you're cleaning up Office-generated HTML, consider using a dedicated tool or a "paste as plain text" option in your CMS to strip out proprietary markup before it enters your pages. This keeps your HTML lean, valid, and maintainable.
