XML declaration allowed only at the start of the document

Posted on 2011-10-22
Last Modified: 2012-06-21
This website:

found the following error:

Line 3, Column 5: XML declaration allowed only at the start of the document <?xml version="1.0" encoding="utf-8"?>

for the HTML file starting with:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
<?xml version="1.0" encoding="utf-8"?>
<html xmlns="">

I'm confused abouit why...

Any idea?
Question by:newbieweb
    LVL 16

    Accepted Solution

    The XML Declaration is required to be the first line on an XML-based file. This is the way the XML standard was written, to let the XML parser know what version of XML the structure conforms to, the encoding, and whether it is standalone:
    LVL 3

    Assisted Solution

    The xml declaration
    <?xml version="1.0" encoding="utf-8"?>

    Open in new window

    must be the first line in the document.

    Try tihs

    <?xml version="1.0" encoding="utf-8"?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    <html xmlns="">

    Open in new window

    See examples here:


    Author Closing Comment


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Adobe Photoshop CC 2015

    Photoshop has become the standard in image manipulation among professional photographers and graphic designers. This course covers exam objectives for the Adobe Certified Associate (ACA) certification.

    Creating a CSS block that only applies to printing By default, all of your CSS applies to every possible view of your page - whether on screen, printed, landscape, touch-screen, or whatever.  You can, however, add CSS that only applies under certai…
    When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
    In this tutorial viewers will learn how to customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
    The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now