Pregunta

I MUST do this page in XHTML1.0 Strict. I try for hours now to get an input tag like <input type="text" />. In the developer console of Firefox & Chrome it kicks out the slash. index.php-file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<head>
    <meta charset="UTF-8">
    <title></title>
    <link rel="stylesheet" media="screen" href="css/default.css">
</head>
<body>
<? include "form.php"; ?>
</body>
</html>

the relevant PHP-Code (This is my last and simpelst test, because i'll start thinking going mad!!):

$inputTagStart = htmlspecialchars_decode('&lt;input name="test" value="andso" /&gt;');

output in Chrome (same in FF)

<input name="test" value="andso">

..and some other versions...

$inputTagStart = htmlspecialchars_decode("<label for='".$data['Label']."'>".$data['Label']."</label><input type='text' name='".$data['Label']."' value='".returnPostedTextData($data['Label'], $data['Default'])."' ".$classRequired." />", ENT_XHTML);

output in Chrome input tag not created

$inputTagStart = htmlspecialchars_decode("&lt;label for='dsf'&gt;df&lt;/label&gt;&lt;input type='text' name='dsf' value='s'/&gt;");

output in Chrome

<input type="text" name="dsf" value="s">

Please help, i don't get it

¿Fue útil?

Solución

A browser's developer console does not show you the actual source of the page (use "view source" for that): it shows you the browser's interpretation of the page content, as modified by javascript (it'll also show the browser's best guess fix for invalid HTML).

If you're outputting XHTML without XHTML headers, browsers will just interpret it as slightly weird HTML, interpret it accordingly, and show that interpretation in their developer consoles.

  • If you want to see the actual XHTML source of the page, use the "view source" option.
  • If you want to see XHTML in the developer console, ensure you're outputting the header Content-Type: application/xhtml+xml.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top