# Saw “<?”. Probable cause: Attempt to use an XML processing instruction in HTML. (XML processing instructions are not supported in HTML.)

> Canonical HTML version: https://rocketvalidator.com/html-validation/saw-probable-cause-attempt-to-use-an-xml-processing-instruction-in-html-xml-processing-instructions-are-not-supported-in-html
> Attribution: Rocket Validator (https://rocketvalidator.com)
> License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/)

XML processing instructions are a feature of XML, not HTML. They begin with `<?` and end with `?>`, and are used in XML documents to carry instructions for applications processing the document. The most common example is the XML declaration: `<?xml version="1.0" encoding="UTF-8"?>`. While these are perfectly valid in XML, the HTML parser does not recognize them. When the parser encounters `<?`, it doesn't know how to handle it and treats it as a bogus comment, which leads to unexpected behavior and this validation error.

This matters for several reasons. First, standards compliance — HTML5 has a clearly defined parsing algorithm, and processing instructions are not part of it. Second, browser behavior becomes unpredictable — different browsers may handle the unexpected `<?` content differently, potentially exposing raw code or breaking your layout. Third, if server-side code like PHP leaks into the output, it can expose sensitive logic or configuration details to end users.

There are three common causes of this error:

**1. Inlining SVG files with their XML declaration.** When you copy the contents of an `.svg` file and paste it directly into HTML, the file often starts with an XML declaration and possibly a `<?xml-stylesheet?>` processing instruction. These must be removed — only the `<svg>` element and its children should be included.

**2. Unprocessed server-side code.** Languages like PHP use `<?php ... ?>` (or the short tag `<? ... ?>`) syntax. If the server isn't configured to process PHP files, or if a `.html` file contains PHP code without being routed through the PHP interpreter, the raw `<?php` tags end up in the HTML sent to the browser.

**3. Copy-pasting XML content.** Other XML-based formats (like RSS feeds, XHTML fragments, or MathML with XML declarations) may include processing instructions that aren't valid in HTML.

## How to Fix It

- **For inline SVGs:** Open the SVG file in a text editor and copy only the `<svg>...</svg>` element. Remove the `<?xml ...?>` declaration and any other processing instructions that precede the `<svg>` tag.
- **For PHP or other server-side code:** Ensure your server is properly configured to process the files. Check that the file extension matches what the server expects (e.g., `.php` for PHP files). Verify that the server-side language is installed and running.
- **For other XML content:** Strip out any `<?...?>` processing instructions before embedding the content in HTML.

## Examples

### ❌ Inline SVG with XML declaration

```html
<body>
  <?xml version="1.0" encoding="UTF-8"?>
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
    <circle cx="50" cy="50" r="40" fill="blue" />
  </svg>
</body>
```

The `<?xml version="1.0" encoding="UTF-8"?>` line triggers the error.

### ✅ Inline SVG without XML declaration

```html
<body>
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100">
    <circle cx="50" cy="50" r="40" fill="blue" />
  </svg>
</body>
```

### ❌ Unprocessed PHP code in HTML output

```html
<body>
  <h1>Welcome</h1>
  <p><?php echo "Hello, World!"; ?></p>
</body>
```

If the server doesn't process the PHP, the raw `<?php ... ?>` ends up in the HTML and triggers this error.

### ✅ Properly processed output (or static HTML equivalent)

```html
<body>
  <h1>Welcome</h1>
  <p>Hello, World!</p>
</body>
```

### ❌ SVG with an XML stylesheet processing instruction

```html
<body>
  <?xml-stylesheet type="text/css" href="style.css"?>
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50">
    <rect width="50" height="50" fill="red" />
  </svg>
</body>
```

### ✅ SVG without the processing instruction

```html
<body>
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50">
    <rect width="50" height="50" fill="red" />
  </svg>
</body>
```

In HTML, use standard `<link>` or `<style>` elements in the `<head>` for stylesheets instead of XML processing instructions.
