1

I am following W3Schools to learn XSLT. in An example. In-line styling is performed here. How can I link an external (CSS) style sheet to style HTML compliant tags?

2 Answers 2

1

As long as the XSLT outputs normal HTML in the browser, this should do the trick:

HTML:

<html>
  <body>
  <h2>My CD Collection</h2>
  <table class="mytable">
    <tr>
      <th>Title</th>
 ...
</table>

CSS:

.mytable
{
border: 1px solid #000;
}

.mytable tr
{
background-color: #9acd32;
}

.mytable th
{
styles
}

Edit:

Seems you need to declare them in a different way, check out this link, it has a very good explanation:

http://www.w3.org/TR/NOTE-XSL-and-CSS

Hope that helps :)

1
  • I have a different working scenario. I am directly exploring xml document from the browser. An associated xsl style sheet defines the HTML like structure for xml nodes. The output is like HTML , means no collapsible hierarchical layout. Here I need to associate an external css to be included to this setup. Do I need to attach it in xsl, xml or in both and how? Jun 15, 2010 at 7:31
0

The way XSL and CSS stylesheets are handled varies between browser. Take IE as example: when you include two process instruction (XSL and CSS) into a XML document, XSL takes precedence over CSS.

I think that the best cross-browser way would be: if you want an external CSS stylesheet for your HTML transformation output, you must add a html:link element into the result tree.

Check, www.aranedabienesraices.com.ar as an example.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.