0

How can create class diagram for CSS? Does it really make sense to have Class Diagram for CSS?

Sled
  • 18,541
  • 27
  • 119
  • 168
Mukesh Kumar
  • 783
  • 1
  • 9
  • 24
  • Could you be more specific? CSS describes styles for elements and attributes. Maybe that is what you want to model? – vainolo Aug 16 '12 at 04:56
  • I have CSS classes defined for HTML page. now i want to create UML class diagram for the these classes. so what strategy can be used to model it? CSS has different type of inheritance where elements can inherit properties from parent elements. – Mukesh Kumar Aug 16 '12 at 06:00

1 Answers1

0

IMO class diagrams don't make much sense for CSS - at least for a 1:1 mapping. Classes do not extend each other but their instances (tags) inherit properties from the enclosing tags. Additionally instances can have many (or no) classes. So there is no inheritance in the sense of UML classes. The difference is explained e.g. here: http://dorward.me.uk/www/css/inheritance/

Additionally there are no associations expressed in CSS. Tag classes cannot relate to each other in a formal way. The actual relations are expressed on instance level - tags relate to each other: http://webdesign.about.com/od/cssselectors/qt/html-tag-relationships.htm

So my conclusion would be: If you really want to use UML, you will need a diagram which describes the instances as well - for example an Object Diagram (Class Daigram with objects) or Components including their instances.

Most likely it will be much better to draw an outline of usual HTML documents and annotate them with classes and applied styles...

Christian
  • 13,285
  • 2
  • 32
  • 49