PHP DOMNode -> setAttribute() max-width confusion

While adding some custom code into Mahara, I came across what seems like a very odd PHP bug today, so odd that I put it down to user error, but just can’t seem to find what the user error is! Imagine the code below with some embed code from youtube or picasa as the value of $embedCode.
$embedCode = "<embed .................></embed>";
$dom = new DOMDocument();
$dom->loadHTML($
embedCode);
$allElements = $dom->getElementsByTagName('*');
$firstElement = $allElements->item(2);
$
firstElement->setAttribute("style", "max-width:100%");
echo $dom->saveHTML();

The line that plays up is the one including setAttribute(“style”, “max-width:100%”).

It works on pretty much all other possible css values, but doesn’t seem to like max-width nor min-width. I can set the style to hold color or background values, or text-align, but not max-width! What gives? Why does PHP seem to have CSS max-width?

EDIT: I have since uncovered the cause of this. My text string was being passed through a Mahara function clean_html() which strips out various things, including max-width style definitions. The solution is to clean_html() before I apply my max-width and hey presto, everything works as expected.

new blog code

After ages of not posting to my former blog, I decided to migrate to some proper blog code. I am now using blogger. I threw together a template that looks mostly like my old site, to make it feel comfortable. The management tools (making posts, etc) for this is so much nicer, I might actually post more often… don’t count on it though 😉