|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51530 DOMDocument::createElement() does not handle <link> correctly
Submitted: 2010-04-11 02:16 UTC Modified: 2010-04-12 16:41 UTC
From: jameswithers89 at googlemail dot com Assigned:
Status: Not a bug Package: DOM XML related
PHP Version: 5.3.2 OS: Fedora 12 GNU/Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: jameswithers89 at googlemail dot com
New email:
PHP Version: OS:


 [2010-04-11 02:16 UTC] jameswithers89 at googlemail dot com
DOMDocument::createElement() does not add a closing </link> tag with DOMDocument::createElement('link'). It outputs <element> rather than <element></element>.

I am using php-5.3.2-1.fc12.i686 and php-xml-5.3.2-1.fc12.i686 installed using Yellowdog Updater, Modified Package Manager. All other DOM methods tried so far work fine.

Test script:
$implementation = new DOMImplementation();
$document = $implementation->createDocument(null, null, $implementation->createDocumentType('html'));
$html = $document->createElement('html');
$head = $document->createElement('head');
$stylesheet = $document->createElement('link');
$title = $document->createElement('title', 'Possible link error');
$body = $document->createElement('body');
$html->setAttribute('xmlns', '');
echo $document->saveHTML();

Expected result:
<!DOCTYPE html>
<html xmlns="">
<link href="style.css" rel="stylesheet" type="text/css"></link>
<title>Possible link error</title>

Actual result:
<!DOCTYPE html>
<html xmlns="">
<link href="style.css" rel="stylesheet" type="text/css">
<title>Possible link error</title>


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-04-12 16:41 UTC]
-Status: Open +Status: Bogus
 [2010-04-12 16:41 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

use saveXML to produce XHTML. In regular HTML link tag has no closing tag
PHP Copyright © 2001-2021 The PHP Group
All rights reserved.
Last updated: Sat Jul 31 04:01:24 2021 UTC