Home >>XML Tutorial >XML CSS
CSS (Cascading Style Sheets) may be used to add style to an XML document and show the information. This will format the whole Document XML.
To link XML files with CSS, you should use the following syntax:
<?xml-stylesheet type="text/css" href="style.css"?>
style.css
employee
{
background-color: blue;
}
firstname,lastname,email
{
font-size:18px;
display:block;
color: white;
margin-left: 30px;
}
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>phptpoint</firstname>
<lastname>Noida</lastname>
<email>phptpoint@phptpoint.com</email>
</employee>