How To Create Table In Xml Using Css

In this blog post, we will discuss how to create a table in XML using CSS. XML (Extensible Markup Language) is a markup language that allows for the creation of custom tags and structures to store and transport data. On the other hand, CSS (Cascading Style Sheets) is a stylesheet language used for styling the appearance of web documents.

Step 1: Create an XML file with table data

First, let’s create an XML file with the data we want to display in the table. For this example, we will use a list of books with their titles, authors, and publication dates. Create a new file called books.xml and paste the following code:

            <title>Book 1</title>
            <author>Author 1</author>
            <title>Book 2</title>
            <author>Author 2</author>
            <title>Book 3</title>
            <author>Author 3</author>

Note the processing instruction at the beginning of the file. This is how we link our XML file to the CSS file that we will create in the next step.

Step 2: Create a CSS file to style the table

Now, let’s create a new file called style.css and paste the following code:

    books {
        display: table;
        width: 100%;
        border-spacing: 0;

    book {
        display: table-row;
        border-bottom: 1px solid #ccc;

    title, author, publicationDate {
        display: table-cell;
        padding: 8px;

In this CSS file, we have styled the books element as a table, the book element as a table row, and the title, author, and publicationDate elements as table cells. We have also added some padding and borders to make the table look better.

Step 3: Display the XML table in a web browser

With the XML and CSS files created, we can now display our table in a web browser. Open your favorite web browser and drag the books.xml file into it. You should see the table with the correct styling applied.


In this blog post, we have shown how to create a table in XML using CSS to style the appearance of the table. This is a useful technique if you need to display structured data in a tabular format, and it can be easily customized to fit your specific needs. Happy coding!