Friday, February 18, 2011

How to use DTD in XML and DTD in HTML documents

Document type declaration (DTD) is simply a notification or instruction put with a HTML or XML to clarify the mode of rendition of the documents in browsers, the version of HTML or XML in use and for validation of the coding. Though there are other factors to use DTD in HTML and DTD in XML. In other words it is the DTD for which the html and XML files properly work. There will arise several issues if the DTD is not properly used with the two file types.
Now here we will try to point out what type of situation may arise if you hire website designer who does not know how to use DTD properly. The coders should mind just a few points mentioned below to use DTD in HTML and DTD in XML. Let’s see the things:
  • DTD in HTML and DTD in XML files are stated to identify the version of the XML or HTML in use. Without this declaration it is not possible to validate the files. All the validation systems use this process to put the mark of ‘standard verified XML or HTML’ against all the XML and html files. So the coders need to add red portion in their declaration.:
                          
                        <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
             "http://www.w3.org/TR/html4/strict.dtd"> 
or 
            <?xml version="1.0" encoding="ISO-8859-1"?>
                <note>
                    <to>Tove</to>
                    <from>Jani</from>
                    <heading>Reminder</heading>
                    <body>Don't forget me this weekend!</body>
                </note>
  
  • If the DTD in HTML and DTD in XML files are not stated properly, the browsers would not understand the mode of XML or HTML to be shown to the viewers. When a browser does not find the DTD description then it directly shows the web pages in quirk mode, if finds out the description then shows the standard mode. In the following example follow the red marked area:
        
                <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
                 "http://www.w3.org/TR/html4/strict.dtd">
                      But look the following one
                            <!DOCTYPE html PUBLIC>

  • Finding only the “public” note the browsers have to render the webpage in quirk mode (a display of web page in older version of a browser for finding DTD in HTML and DTD in XML files.  It is because the coding is not compiling with the latest validation updates provided to current browser version).
  • Suppose the client browser does not support the latest updated CSS formats you have used in your coding, what would be the display or how will you be able to show the web pages in proper condition on those browsers? Answer is very simple use “transitional” mode of coding. But if the case is otherwise the mode of DTD in HTML and DTD in XML files will be “strict”. See the coding below:

<!DOCTYPE HTML PUBLIC
                                                "-//W3C//DTD HTML 4.01 Transitional//EN"
                                                 "http://www.w3.org/TR/html4/loose.dtd">
            Or simply 
           <!DOCTYPE HTML PUBLIC
                                               "-//W3C//DTD HTML 4.01//EN"
                                               "http://www.w3.org/TR/html4/strict.dtd">

  • Now there may be some cases when you need to code or use DTD in HTML and DTD in XML files for your private view. The web pages will be visible in your system only. How would you stop the public view of those pages? The answer is very simple use “system” keyword in the coding, instead of “Public”. Look at the code below:
                    
                    <?xml version="1.0" encoding="ISO-8859-1"?>
                    <!DOCTYPE note SYSTEM "Note.dtd">
                    <note>
                        <to>Tove</to>
                        <from>Jani</from>
                        <heading>Reminder</heading>
                        <body>Don't forget me this weekend!</body>
                    </note>

If you write “public” at the place of the “system” the pages will be visible to the world. So DTD in HTML and DTD in XML files has to carefully state if the pages are to be viewed by public or not. A small mistake may disclose huge confidential matters to the world.
  • Without the proper DTD in HTML and DTD in XML files the page elements may not come in display. Particularly in the XML files DTD are the building blocks to structure the legal elements. If there is any mistake the complete coding will be useless. On the other hands many a times XML data is shared within various groups. In such cases if common DTD is not present, sharing will not be possible.

However in this way you may have understood how to use the DTD in HTML and DTD in XML properly. There are many other document type declarations for proper functioning of the XML and the HTML files. I have only tried to exemplify the few ways to use it. But here I must tell you one thing for sure, there are many coders who do not perform these tasks or take this ways to make the web pages perfectly functioning in all the browsers. As a freelance graphic designer, I never feel any lethargy to make the DTD in HTML and DTD in XML perfect for all my client sites.  I know how to make my clients satisfied with best of design and development. Hope you find the best coding for your web building purposes! 

No comments:

Post a Comment

My Ping in TotalPing.com
Feedage Grade D rated
Preview on Feedage: web-design Add to My Yahoo! Add to Google! Add to AOL! Add to MSN
Subscribe in NewsGator Online Add to Netvibes Subscribe in Pakeflakes Subscribe in Bloglines Add to Alesti RSS Reader
Add to Feedage.com Groups Add to Windows Live iPing-it Add to Feedage RSS Alerts Add To Fwicki
Ping your blog, website, or RSS feed for Free