Css 顶级xml元素";学生“;韩元';t色

Css 顶级xml元素";学生“;韩元';t色,css,xml,Css,Xml,我知道这听起来像是一个常见的问题,但我搜索了整个堆栈溢出,没有找到任何东西。我现在遇到的问题是顶级xml元素“Students”无法从css中获得背景色。我正确地嵌套了xml和所有内容,并且在css文件中正确地拼写了xml元素。我尝试了xml验证器,文档的格式似乎很好。那么有什么可能是错误的呢 这是XML <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/css" href="stylexml.

我知道这听起来像是一个常见的问题,但我搜索了整个堆栈溢出,没有找到任何东西。我现在遇到的问题是顶级xml元素“Students”无法从css中获得背景色。我正确地嵌套了xml和所有内容,并且在css文件中正确地拼写了xml元素。我尝试了xml验证器,文档的格式似乎很好。那么有什么可能是错误的呢

这是XML

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="stylexml.css"?>
<Registration>
    <Student>
        <Id>0001234567</Id>
        <University>Indiana University Purdue University Indianapolis</University>
        <Education>Undergraduate</Education>
        <Category>Technology Undergraduate</Category>
        <Degree>Computer Tech BS</Degree>
    </Student>
    <Semester>
        <Season>Spring Semester</Season>
        <Year>2004-2005</Year>
        <Bterm>Senior</Bterm>
        <Eterm>Senior</Eterm>
    </Semester>     
    <Class id="0">
        <Course>CIT 412</Course>
        <Number>12981</Number>
        <Section>0100</Section>
        <Description>XML-BASED WEB APPLICATIONS</Description>
        <Component>Lecture</Component>
        <Grading>Graded</Grading>
        <Grade> </Grade>
        <Units>3.00</Units>
        <Status>Enrolled</Status>
        <!--New instance of schedule only created if time or location differs on weekdays-->
        <Schedule id="0">
            <Start>1:00PM</Start>
            <End>2:15PM</End>
            <Weekday>Mon,Wed</Weekday> 
            <Location>SL SL223</Location>
        </Schedule>
        <Instructor>Fernandez, Eugenia</Instructor>
        </Class>
    <Class id="1">
        <Course>CIT 479</Course>
        <Number>12988</Number>
        <Section>0100</Section>
        <Description>DATABASE IMPLEMENTATN &amp; ADMIN</Description>
        <Component>Lecture</Component>
        <Grading>Graded</Grading>
        <Grade> </Grade>
        <Units>3.00</Units>
        <Status>Enrolled</Status>
        <Schedule id="0">
            <Start>7:15PM</Start>
            <End>8:30PM</End>
            <Weekday>Mon</Weekday> 
            <Location>SL SL223</Location>
        </Schedule>
        <Schedule id="1">
            <Start>7:15PM</Start>
            <End>8:30PM</End>
            <Weekday>Wed</Weekday> 
            <Location>SL SL216</Location>
        </Schedule>
        <Instructor> </Instructor>
    </Class>
    <Class id="2">
        <Course>MATH M-119</Course>
        <Number>15304</Number>
        <Section>0400</Section>
        <Description>BRIEF SURVEY OF CALCULUS 1</Description>
        <Component>Lecture</Component>
        <Grading>Graded</Grading>
        <Grade> </Grade>
        <Units>3.00</Units>
        <Status>Enrolled</Status>
        <Schedule id="0">
            <Start>5:45PM</Start>
            <End>7:15PM</End>
            <Weekday>Mon,Wed</Weekday> 
            <Location>LE 104</Location>
        </Schedule>
        <Instructor>Tam,Richard Yiu-Hang</Instructor>
    </Class>
</Registration>

在渲染中,需要将
Student
元素声明为块元素:

Student { display: block }
默认情况下,它是一个内联元素,因为在XML中,
display
的初始值(
inline
)在没有样式表为属性赋值且属性未继承时使用(
display
)。因此
Student
将是一个可怜的、孤独的内联元素,它的所有子元素都占据了它们的块,没有留下任何背景。如果只在
Student
元素中添加纯文本,您可以看到这一点:它将采用红色背景

在渲染中,元素不会因为其子元素是块元素而成为块元素


请注意,您的代码具有格式错误的行
//背景颜色:蓝色。根据CSS错误处理规则,它将被忽略,但它仍然是一个错误;您不能在CSS中使用JavaScript注释;相反,CSS中的注释的形式是
/*注释文本*/

其他CSS样式是否应用于其他标记?是的,其他CSS标记工作正常。
Student { display: block }