0

For example i have a DTD

DTD:
<!ELEMENT tbl EMPTY>
<!ATTLIST tbl tableWidth CDATA "0">
<!ELEMENT MyImage EMPTY>
<!ATTLIST MyImage source CDATA "sample.png">

Valid XML:
<tbl tableWidth ="100" />
<MyImage source="image.png"/>

Now in CSS for element tbl I can specify it as

tbl {
    display: table;
}

This means that element tbl should be displayed as table. But if we want to display MyImage element as image how can we do that? Image should come from source attribute. As there is no image value for display css property.

BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
Jitendra
  • 732
  • 1
  • 9
  • 29
  • "...there is no image value for display css property." No...there isn't. If you want to use an image...use an image. It's not clear what you are trying to do. – Paulie_D Sep 08 '15 at 09:14
  • I have a custom xml. Which i would like to open in tools like oxygen which support css. In css i want to specify an element as of type image so that these tool can render specified element as image. – Jitendra Sep 08 '15 at 09:18
  • Well, I confess, I'm not familiar with XML but there is no `display:image` in CSS so I dont know what to tell you. – Paulie_D Sep 08 '15 at 09:29
  • @Paulie_D then there is also table element in html then why have table value for display property? – Jitendra Sep 08 '15 at 09:31
  • Because you might want element to *behave* like a table..but an image is an image and can't be, or behave, like anything else. – Paulie_D Sep 08 '15 at 09:32

1 Answers1

1

In CSS, an image is a replaced element,

An element whose content is outside the scope of the CSS formatting model, such as an image, embedded document, or applet.

This means CSS doesn't define how replaced content is rendered. It's left entirely to the user agent. And this is why there is no display: image value.

If only browsers implemented CSS3's attr(), you could cheat by doing something like this (which actually results in a replaced pseudo-element):

MyImage::before {
  content: attr(source url);
}

But since no browser still implements it as of today, you're pretty much stuck. (Technically the supposed way to do this is to implement a custom user agent for your XML, but I'm not sure most authors are prepared for that.)

Community
  • 1
  • 1
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356