CSS (Cascading Style Sheets) can be used to add style and display information to an XML document. It can format the whole XML document.
To link XML files with CSS, you should use the following syntax:
<?xml-stylesheet type="text/css" href="cssemployee.css"?>
Let's see the css file.
cssemployee.css
employee { background-color: pink; } firstname,lastname,email { font-size:25px; display:block; color: blue; margin-left: 50px; }
Let's create the DTD file.
employee.dtd
<!ELEMENT employee (firstname,lastname,email)> <!ELEMENT firstname (#PCDATA)> <!ELEMENT lastname (#PCDATA)> <!ELEMENT email (#PCDATA)>
Let's see the xml file using CSS and DTD.
employee.xml
<?xml version="1.0"?> <?xml-stylesheet type="text/css" href="cssemployee.css"?> <!DOCTYPE employee SYSTEM "employee.dtd"> <employee> <firstname>vimal</firstname> <lastname>jaiswal</lastname> <email>vimal@rookienerd.com</email> </employee>