@@ -71,7 +71,7 @@ Adding HTML Attributes
7171----------------------
7272
7373That's all well and good, but there's more to HTML than just text. What if we wanted to
74- display an image? In HTMl we'd use the `<img/> ` element and add attributes to it order
74+ display an image? In HTMl we'd use the `` <img> ` ` element and add attributes to it order
7575to specify a URL to its ``src `` and use some ``style `` to modify and position it:
7676
7777.. code-block :: html
@@ -80,23 +80,27 @@ to specify a URL to its ``src`` and use some ``style`` to modify and position it
8080 src =" https://picsum.photos/id/237/500/300"
8181 style =" width : 50% ; margin-left : 25% ;"
8282 alt =" Billie Holiday"
83+ tabindex =" 0"
8384 />
8485
85- In IDOM we add these attributes to elements using dictionaries. There are some notable
86- differences though. The biggest being the fact that all names in IDOM use ``camelCase ``
87- instead of dash-separated words. For example, ``margin-left `` becomes ``marginLeft ``.
88- Additionally, instead of specifying ``style `` using a string, we use a dictionary:
86+ In IDOM we add these attributes to elements using keyword arguments. There are two main
87+ notable differences though. First, all names in IDOM use ``snake_case `` instead of
88+ dash-separated words. For example, ``tabindex `` and ``margin-left `` become ``tab_index ``
89+ and ``margin_left `` respectively. Second, instead of specifying ``style `` using a
90+ string, we use a dictionary. Given this, you can rewrite the ``<img> `` element above as:
8991
9092.. testcode ::
9193
9294 html.img(
9395 src="https://picsum.photos/id/237/500/300",
94- style={"width": "50%", "marginLeft ": "25%"},
96+ style={"width": "50%", "margin_left ": "25%"},
9597 alt="Billie Holiday",
98+ tab_index="0",
9699 )
97100
98101.. raw :: html
99102
103+ <!-- no tabindex since that would ruin accesibility of the page -->
100104 <img
101105 src =" https://picsum.photos/id/237/500/300"
102106 style =" width : 50% ; margin-left : 25% ;"
0 commit comments