css - Howto assign HTML semantics to my XML elements to get them rendered in my web browser? -
i have xml file this:
<?xml version="1.0" encoding="utf-8"?> <todo> <list><item>first</item><item>second</item></list> <list><item>first</item><item>second</item></list> </todo> now want view file in browser. want have <list> element rendered <ul> html-element, <item> elements <li> html-elements. know can use xslt transform xml html document. but: there way directly assign html semantics elements of list, e.g. css (something list{display:ul}) or dtd?
yes, possible.
see w3c-website style sheets xml.
you can use css declare each xml element how browser should display it. have more verbose in html, because plain xml there no predefined styles.
in xml header add reference css file:
<?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/css" href="todo.css"?> <todo> <list><item>first</item><item>second</item></list> <list><item>first</item><item>second</item></list> </todo> here example css file (todo.css):
todo { display: block; } list { display: block; padding-left: 5mm; margin-top: 1cm; } item { display: list-item; list-style-type: circle; } for each element can define display style (block, inline, none, list-item).
for display: list-item can additionally use styles
list-style-image: url(bullet.gif)decalare bullet icon graphiclist-style-imagevaluesinsideoroutsidelist-style-typevaluescircle,disc,square,none
Comments
Post a Comment