![]() | the sleepy snakeindex :: html :: TagInstances | |||||||||||||||||||||||||||||||||
tagsThe html module supports all tags and attributes as specified in http://www.htmlhelp.com/reference/html40/. All tag classes in the module use names with the first letter capitalzed. HTML --> Html, TABLE --> Table, B --> B. All tag attributes are handled and should be specified lowercase. All tags are derrived from the following base classes:
Tag instances provide the following attributes:
Tag instances provide the following class attributes (considered readonly):
Tag instances provide the following methods:
There are two ways to construct HTML content. One is by using list methods: from html import * tr = Tr() tr.children.extend([Td(), Td()]) t = Table() t.children.append(tr) The other is more layout centric and more readable, using call() from html import *
t = (
Table()
(
Tr()
(
Td(),
Td()
)
)
)
Notes:
attributesattributes may be specified at initialization time or by accessing a tags attrs dict. Attribute values must always be specified as strings. a = A(href="foo/bar")
a = A(**{"href": "foo/bar"})
a = A()
a.attrs["href"] = "bar"
a.attrs = {"href": "foo/bar", "name": "baz"}
# as a convenience, because it is so commonly used,
# class may be specified keyword clss (constructor only)
a = A(clss="foo")
# flag attributes are set by passing "" (empty string) as value
a.attrs["cant_think_of_one_right_now"] = ""
child tagschild tags of a tag are always stored as list ul = Ul() ul.children = [Li(), Li()] | ||||||||||||||||||||||||||||||||||