Here's how I change the value of an existing attribute:

Code:
element.attribute = "value"
But is it OK to use the above method to create a new attribute?