Matrices with XHTML & CSS

In a quest to display mathematics on the web, it was desirable to find a method to display matrices by means of X(HT)ML and CSS. Currently no real matrices can be created due to limitations in border styles, but a close attempt is possible. The approach outlined below allows ordening in columns (i.e. vectors) instead of rows such as tables, requires little markup and scales quite easily. It is however limited, because the border-colours have to be chosen with care.

This page is also available as XML with similar layout, but much reduced markup, replacing divs and classes by custom tags.

Examples

The outer div with the borders is display:inline-table (to allow multiple matrices on one line), the vectors are display:inline-table (to allow multiple vectors in one matrix) and the cells are display:block (which will force the cells to show below each other). In this setup both the vectors and the cells are coloured. Individual styling is always possible of course.

11
21
31
12
22
31
11
21
12
22
=
11
21
31
12
22
31

The next example uses transpose vectors to create rows. The rows are display:table and the cells are display:table-cell. It is to be solved for a vector.

11
12
13
21
22
23
a
b

A difficulty here is the rows cannot easily be given a background-color, as possible with the vectors, because background-color won't apply to table-row.

Alternatives

Styling separate columns and row is also possible with tables and col/rowgroups and such but using the above technique may have advantages when further developed:

© 2004-2006, Mark Schenk.