Looking for assistance with CSS coding for an XML table

Struggling with styling an XML file into a table using CSS. Despite multiple attempts, I just can't seem to achieve the desired look.

Provided below is my XML code. Seeking assistance from anyone who can offer a solution to this perplexing issue.

<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="record.css" ?>

 <Record>

<data> 
<data-header> StudentId </data-header> 
<data-header> Surname </data-header> 
<data-header> Name </data-header> 
<data-header> Course </data-header> 
</data>

<data> 
<data-cell> 00123 </data-cell> 
<data-cell> Jack </data-cell>
<data-cell> Jim </data-cell> 
<data-cell> BSc </data-cell> 
</data>

<data> 
<data-cell> 00124 </data-cell> 
<data-cell> Jenny </data-cell>
<data-cell> Janet </data-cell> 
<data-cell> Diploma </data-cell>
</data>

 </Record>

The existing CSS code that does not meet the desired outcome:

Record { 
    display:table; 
    font-size:14px; 
    margin:8px; 
    font-family: Verdana; display:block 
} 
data{ 
    display:block; 
    text-align:center; 
    border: 1px solid silver; 
    padding:10px; 
    background-color:whitesmoke; 
} 
data-cell,data-header { 
    display: table-cell; 
    border: solid 1px; 
}

Desired layout specifications include:

  • Four headers in the first line
  • All content should be centered (both headers and data)
  • Cells maximize space in each column
  • Each column occupies 25% of the total width

Answer №1

Give this a shot:

Stylesheet { 
    display:grid; 
    font-size:16px; 
    margin:12px; 
    font-family: Arial; 
    width: 100%;
} 
info{ 
    display:grid-row; 
    text-align:center; 
    border: 2px solid gray; 
    padding:12px; 
    background-color:gainsboro; 
} 
info-box,info-header { 
    display: grid-cell; 
    border: dashed 1px; 
    width: 30%;
}

Feel free to test it out on JSFiddle

You had utilized block rather than table-row. The remaining attributes can be adjusted using width.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

A subtle background image with an overlay of a transparent RGBA gradient

Currently, I am working on designing the header of a website. My goal is to incorporate an image on the right side of the header, overlayed with a gradient color that has a certain level of transparency set using rgba values. Although the image and gradien ...

Video posters can now feature a sleek black border to enhance the

How can I add a black border to a video poster? I've tried to work it out on my own, but I'm having trouble getting it to work. Thank you for any assistance... echo '<video id="video" width="300px" height="200px&q ...

Creating a top-to-bottom pull effect on a single page, similar to the Android title bar, can be achieved using CSS3

Is there a way to achieve an effect in HTML that resembles the pull title bar animation from top to bottom in Android? Any suggestions on how to create this effect or what tools I would need? Currently, when I swipe, the page simply displays a following ...

What is the best way to place tfoot at the top of the table

Below is the structure of my table: https://i.stack.imgur.com/QmlVn.png In the table, there are search input fields at the bottom of each column. I would like to move them to the top, right after the <thead> </thead>. The basic HTML code for ...

What is the procedure for inserting comments into inline CSS?

You know, I've been wondering how to effectively comment out inline CSS styles within HTML tags. Is it best to use the /* */ comments from CSS? Or should we opt for <!-- --> in HTML? <span class="color_dark" style="top:20px;font-size: 17px;l ...

Enhancing the appearance of the MUI DatePicker

I'm currently using a DatePicker component from Mui Lab and I'm attempting to customize the appearance of the Calendar component by incorporating some border or background color. Although I've tried utilizing the PaperProps prop for DatePick ...

Attempting to position two buttons and a logo in the footer with the help of Bootstrap!

Currently working on a new website project utilizing Bootstrap-4 My goal is to position a logo to the left, a link button in the center, and another link button to the right within a footer div. So far, I've managed to achieve the layout, but the iss ...

When using VueJS to load an SVG file based on a variable within a for loop and utilizing v-html, the result returned is "[

I'm faced with a challenge of loading SVGs saved in separate files based on the content within a loop. Upon page load, what I see is: https://i.sstatic.net/OiwyT.png Hey there, check out my code snippet below: <div v-for="(rec, index) in stats ...

How to center the navigation text on a WordPress website within the header.php file

Check out my website at I'm looking to center the navigation menu under the image. I've attempted multiple methods but can't seem to figure it out. Here's a snippet from the header.php file: <center><img src="http ...

What is the simplest method to create a scroller for engaging narratives?

I am in the process of creating a static but responsive storytelling website using HTML. My objective is to create an effect similar to this: https://i.stack.imgur.com/zIEpU.gif The idea is to have text on the left and a *.jpg image fixed on the right. As ...

Placing error notifications beneath my table rows for a more polished appearance

In the process of creating a review page for my app that showcases uploaded files, I've encountered an issue. Whenever a user uploads files with errors, I want to display a warning message below each specific file. Currently, I'm able to show the ...

Align the bottom borders to the lowest content on each line

I am working on designing my homepage using HTML, CSS, JSP, and JavaScript, focusing on the sale of musical instruments and facilitating communication among users. Right now, I am in the process of creating a site-map for my menu configuration chart using ...

`CSS Animation fails to run in Internet Explorer and Microsoft Edge browsers`

My issue with the CSS animation is that while the opacity animates properly, the translate effect does not seem to work as expected. You can see the problem here: https://jsfiddle.net/bLxb8k3s/ It appears that the reason for this issue is because IE and ...

Arranging an image and button within a column div row using Bootstrap

I'm encountering an issue with Bootstrap where I am trying to align the blue buttons neatly below the image. Link to the image: img Here is a visual representation: https://i.sstatic.net/tB5mU.png This is the code snippet: <div class="row&q ...

What is the best way to make a CSS element embrace another element positioned either above or below it?

I've been attempting to arrange multiple CSS shapes to hug each other, but I'm facing some difficulties. After researching online, the only solution I came across was using inline-block. However, I'm struggling to achieve the desired outcome ...

Verify that the text entered in the form is accurate, and if it meets the required criteria, proceed to the next

Is it possible to achieve this without using JavaScript? If not, I'd like to find the simplest solution. I have a form that functions similar to a password entry field, and I would like to redirect users to a certain page if they type in a specific p ...

Tips for adjusting the color of a pin without altering anything else

I have a Google Marker with a default design. By default, I can create the pin with letters inside it. However, I want to change the color of this pin. So, I attempted to use this icon: https://i.sstatic.net/gFXMR.png Unfortunately, the letters shifted ...

steps for marking comments as read or unread by multiple users

I'm working on a development blog for my project and I'd like to add a feature where users can mark comments as unread until they view them. For example, if an admin posts a comment, all users in that project should see it as unread. Can anyone ...

Customize the active text color of breadcrumbs in Bootstrap

My goal is to change the text color "About us" in the breadcrumb to black, but my attempts have been unsuccessful. <ol class="breadcrumb"> <li class="disabled"><a href="index.html">Home</a></li> <li class="active"& ...

How to effectively combine css() and delay() in jQuery?

fid: https://jsfiddle.net/k13sazuz/ Is there a way to create a delay chain for CSS rules using jQuery? $('.two').css('background','blue').delay(11800).css('background','red'); ...