What is the difference between DTD and XSD

Before getting into the difference between DTD and XSD, lets take a look at XML, eXtensible Markup Language.

XML is basically used to store, exchange or transfer between Software Programs or Applications.
Almost any complex data can be represented using XML.
Most of the popular software languages and third party software provides XML parsers.
Application Settings or Configurations, are generally stored in a XML file.

Difference between XML and HTML

Though both are Markup Languages. Purpose of both XML and HTML is entirely different.
HTML(Hyper Text markup Language) is used to display web pages on Web Browser. Web Browsers like Chrome, Firefox, Internet Explorer,etc… parses and renders the HTML file being server, from Web Server.
In HTML tags are pre defined, and we cannot create new HTML Tags.
Another Advantage of XML is data represented or transferred is language and platform independent.

But purpose of XML is to store, exchange or transfer data.In XML we can create our own tags or elements, and we can specify name of the tag, data type, etc…

How DTD and XSD differ

1. Both DTD and XSD are used to describe an XML document.
2. DTD stands for Document Type Definition. XSD stands for XML Schema Docment.
3. DTD is older approach, where as XSD is latest one.
4. XSD has almost replaced DTD, though old ones continue to exist in DTD.
5. DTD provide only two data types CDATA and PCDATA, where as XSD provides more data types such as int, decimal, etc…
6. XSD has more control over restricting only certain values to an element or Attribute like only positive or negative values are allowed etc…, where as DTD do not restrict
7. XSD supports namespaces to avoid name collision between elements having same name.
8. XSD uses XML syntax, but DTD does not.

You may also like to read:
how to use Marquee tag in HTML
input tags in HTML