-
Notifications
You must be signed in to change notification settings - Fork 0
/
attributes.go
1817 lines (1713 loc) · 80.4 KB
/
attributes.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
package attr
import "github.com/jeffswenson/sanity/pkg/html"
// Abbr constructs an html.Node for the `abbr` attribute.
//
// The `abbr` attribute is used to specify an abbreviation or acronym for an
// HTML element. It helps provide a concise description or clarification of the
// element's content. When the abbreviation or acronym is added to an element
// with the `abbr` attribute, browsers and assistive technologies can display a
// tooltip or provide additional context for the abbreviation. This attribute
// is particularly useful for improving accessibility and enhancing the
// understanding of complex terms or technical jargon.
//
// Example Usage:
// <abbr title="World Wide Web Consortium">W3C</abbr>
// <p>The <abbr title="HyperText Markup Language">HTML</abbr> standard is used for creating web pages.</p>
func Abbr(value string) html.Node {
return html.NewAttribute("abbr", value)
}
// Accept constructs an html.Node for the `accept` attribute.
//
// The `accept` attribute is used to specify the types of files that can be
// uploaded through an HTML file input element. It allows developers to
// restrict the file types that users can select for uploading, providing a
// more controlled and secure file input experience. The value of the `accept`
// attribute should be a comma-separated list of file extensions or MIME types.
//
// Example usage:
// <input type="file" accept=".jpg, .png">
func Accept(value string) html.Node {
return html.NewAttribute("accept", value)
}
// AcceptCharSet constructs an html.Node for the `accept-charset` attribute.
//
// `accept-charset` is used to specify the character encodings that are
// accepted by the server when submitting a form. It allows the browser to
// inform the server about the character encoding used in the submitted form
// data, ensuring that the server can correctly interpret and process the data.
// The value of the `accept-charset` attribute is a space-separated list of
// character encoding names.
//
// Example Usage:
// <form action="/submit" method="post" accept-charset="UTF-8">
// <!-- Form fields here -->
// <input type="submit" value="Submit">
// </form>
func AcceptCharSet(value string) html.Node {
return html.NewAttribute("accept-charset", value)
}
// AccessKey constructs an html.Node for the `accesskey` attribute.
//
// `accesskey` is used to specify a keyboard shortcut for quickly accessing an
// HTML element. It allows users to navigate through the webpage using keyboard
// shortcuts instead of relying on a mouse. When the user presses the specified
// key combination (usually a letter or a number) along with the defined
// accesskey attribute, the focus is moved to the associated element. This
// attribute improves accessibility and makes navigation more efficient for
// users who may have difficulty using a mouse.
//
// Example Usage:
// <input type="text" accesskey="u">This input field can be accessed quickly with the 'Alt+U' key combination.
// <button accesskey="s">This button can be triggered using the 'Alt+S' key combination.
// <textarea accesskey="e">This textarea can be focused with 'Alt+E' key combination.
func AccessKey(value string) html.Node {
return html.NewAttribute("accesskey", value)
}
// Action constructs an html.Node for the `action` attribute.
//
// `action` is used to specify the URL of the server-side script or program that
// will process the data submitted through an HTML form. It is primarily used in
// the `<form>` element and determines where the form data will be sent for
// processing. When the form is submitted, the browser will navigate to the URL
// specified in the `action` attribute, sending the form data along with it. This
// allows the server to receive and process the data, and provide a response back
// to the user.
//
// Example Usage:
// <form action="/submit-form" method="POST">
// <!-- Form inputs go here -->
// <input type="submit" value="Submit">
// </form>
func Action(value string) html.Node {
return html.NewAttribute("action", value)
}
// Allow constructs an html.Node for the `allow` attribute.
//
// `allow` is used in HTML5 to specify the types of content that are allowed to
// be displayed or executed within an `<iframe>` element. This attribute
// provides an additional layer of security by allowing the website developer
// to restrict the actions that can be performed within the embedded content.
// The value of the `allow` attribute can include one or more of the following
// keywords: `accelerometer`, `autoplay`, `camera`, `encrypted-media`,
// `fullscreen`, `geolocation`, `gyroscope`, `magnetometer`, `microphone`,
// `midi`, `payment`, and `picture-in-picture`. Each keyword represents a
// specific capability that can be enabled or disabled within the `<iframe>`.
//
// Example Usage:
// <iframe src="https://www.example.com"
// allow="accelerometer; fullscreen; camera;"></iframe>
func Allow(value string) html.Node {
return html.NewAttribute("allow", value)
}
// Alt constructs an html.Node for the `alt` attribute.
//
// `alt` is used to provide alternative text for an image in an HTML document.
// This text is displayed if the image fails to load or cannot be displayed for
// some reason. The `alt` attribute is important for accessibility, as it allows
// screen readers to describe the image to visually impaired users. It also helps
// with search engine optimization (SEO) by providing relevant information about
// the image to search engines. The value of the `alt` attribute should be brief
// but descriptive, conveying the purpose or content of the image.
//
// Example Usage:
// <img src="example.jpg" alt="A beautiful sunset over the ocean">
func Alt(value string) html.Node {
return html.NewAttribute("alt", value)
}
// As constructs an html.Node for the `as` attribute.
//
// `as` is used to specify the expected media type or format of a linked resource
// in an HTML document. It is primarily used in the `link` and `script` tags to
// inform the browser how to handle or interpret the resource. This attribute helps
// optimize the loading and rendering of web content by enabling the browser to
// begin processing the resource even before it is fully downloaded. Common values
// for the `as` attribute include `image`, `style`, `font`, `script`, and `fetch`.
//
// Example Usage:
// <link rel="stylesheet" href="styles.css" as="style">
// <script src="script.js" as="script"></script>
// <img src="image.jpg" alt="Example Image" as="image">
func As(value string) html.Node {
return html.NewAttribute("as", value)
}
// AutoCapitalize constructs an html.Node for the `autocapitalize` attribute.
//
// `autocapitalize` is used to specify whether or not text input in an HTML
// element should be automatically capitalized. This attribute is particularly
// useful for input fields where the user is expected to enter text in a
// specific capitalization style, such as names or addresses. The value of the
// `autocapitalize` attribute can be set to various options, such as "none" (to
// disable automatic capitalization), "sentences" (to capitalize the first letter
// of each sentence), "words" (to capitalize the first letter of each word), or
// "characters" (to capitalize every character).
//
// Example Usage:
// <input type="text" autocapitalize="words" placeholder="Enter your name">
// <input type="text" autocapitalize="none" placeholder="Enter a lowercase email">
func AutoCapitalize(value string) html.Node {
return html.NewAttribute("autocapitalize", value)
}
// AutoComplete constructs an html.Node for the `autocomplete` attribute.
//
// The `autocomplete` attribute is used to specify whether or not an input
// field should have autocomplete functionality enabled. Autocomplete
// functionality provides suggestions or predictions as the user types, based
// on previously entered values or a predefined list. This attribute can have
// the values "on" or "off" to control the behavior of autocomplete.
//
// Example Usage:
// <input type="text" name="username" autocomplete="off">
// <input type="password" name="password" autocomplete="on">
func AutoComplete(value string) html.Node {
return html.NewAttribute("autocomplete", value)
}
// Blocking constructs an html.Node for the `blocking` attribute.
//
// The `blocking` attribute is used to indicate whether a specified resource
// should block the rendering of the HTML document until it is fully loaded or
// not. By default, all resources, such as stylesheets and scripts, are
// considered blocking, meaning that the loading of the resource will delay the
// rendering of the page until it is finished loading. However, by setting the
// `blocking` attribute to "none" on a particular resource, it allows the HTML
// document to continue rendering, while the resource is fetched in the
// background.
//
// Example Usage:
// <link href="styles.css" rel="stylesheet" blocking="none">
// <script src="script.js" blocking="none"></script>
func Blocking(value string) html.Node {
return html.NewAttribute("blocking", value)
}
// CharSet constructs an html.Node for the `charset` attribute.
//
// The `charset` attribute is used to specify the character encoding for an
// HTML document. It tells the browser how to interpret the text within the
// document, ensuring that special characters and symbols are displayed
// correctly. The value of the `charset` attribute is usually set to a specific
// encoding, such as UTF-8 or ISO-8859-1.
//
// Example Usage:
// <meta charset="UTF-8">
func CharSet(value string) html.Node {
return html.NewAttribute("charset", value)
}
// Cite constructs an html.Node for the `cite` attribute.
//
// `cite` is used to specify the source or reference for a quoted or cited
// content within an HTML document. It is primarily used in blockquote or q tags
// to provide a link or reference to the original author, publication, or source
// of the quoted text. The `cite` attribute helps to attribute and provide
// credibility to the quoted content.
//
// Example Usage:
// <blockquote cite="https://www.example.com/article">Lorem ipsum dolor sit
// amet.</blockquote>
func Cite(value string) html.Node {
return html.NewAttribute("cite", value)
}
// Class constructs an html.Node for the `class` attribute.
//
// The `class` attribute is used to assign one or more class names to an HTML
// element, allowing developers to apply CSS styles or JavaScript functionality
// to specific elements. This attribute helps in customizing the appearance and
// behavior of the element by associating it with predefined styles and
// behaviors defined in CSS or JavaScript files. The value of the `class`
// attribute is a space-separated list of class names, enabling multiple styles
// or behaviors to be applied simultaneously.
//
// Example Usage:
// <div class="red-text bold">This div has the classes 'red-text' and 'bold' applied to it.</div>
func Class(value string) html.Node {
return html.NewAttribute("class", value)
}
// Color constructs an html.Node for the `color` attribute.
//
// The `color` attribute is used to specify the text color of an HTML element.
// It allows developers to customize the appearance of text by setting a
// specific color. The value of the `color` attribute can be a named color
// (e.g. "red", "blue"), a hexadecimal color code (e.g. "#FF0000"), or an RGB
// value (e.g. "rgb(255, 0, 0)"). By applying the `color` attribute to an HTML
// element, the text within that element will be displayed in the specified
// color.
//
// Example Usage:
// <p style="color: red;">This text is displayed in red.</p>
func Color(value string) html.Node {
return html.NewAttribute("color", value)
}
// Cols constructs an html.Node for the `cols` attribute.
//
// `cols` is used to specify the number of columns in an HTML table. It
// determines the layout and organization of data within the table, allowing
// developers to define the width of each column. The value of the `cols`
// attribute is an integer that represents the number of columns. This
// attribute helps in creating structured and organized tables with consistent
// column widths.
//
// Example Usage:
// <table cols="3">
// <tr>
// <td>Column 1</td>
// <td>Column 2</td>
// <td>Column 3</td>
// </tr>
// <tr>
// <td>Data 1</td>
// <td>Data 2</td>
// <td>Data 3</td>
// </tr>
// </table>
func Cols(value string) html.Node {
return html.NewAttribute("cols", value)
}
// ColSpan constructs an html.Node for the `colspan` attribute.
//
// `colspan` is used to specify the number of columns a cell should span in an
// HTML table. It allows for the merging of multiple columns in a single cell,
// creating a wider cell that spans across multiple columns. This attribute is
// helpful when there is a need to combine multiple cells horizontally to display
// a larger block of content or data within a table.
//
// Example Usage:
// <td colspan="2">This cell spans across two columns.</td>
func ColSpan(value string) html.Node {
return html.NewAttribute("colspan", value)
}
// Content constructs an html.Node for the `content` attribute.
//
// The `content` attribute is used to specify the content for a specific
// HTML element. It is commonly used with the `meta` element to provide
// additional information about the webpage, such as the author, description,
// or keywords. The value of the `content` attribute can vary depending on
// the context and purpose of the element it is used with.
//
// Example Usage:
// <meta name="description" content="This is a description of the webpage.">
// <meta name="keywords" content="html, attribute, content, example">
func Content(value string) html.Node {
return html.NewAttribute("content", value)
}
// ContentEditable constructs an html.Node for the `contenteditable` attribute.
//
// The `contenteditable` attribute is used to make an HTML element editable by
// the user. When this attribute is set to "true", the element can be modified
// directly on the webpage, allowing users to input text or make changes to the
// content. This attribute is commonly used in web applications or content
// management systems where users need to edit or update text without using a
// separate text editor.
//
// Example Usage:
// <div contenteditable="true">This is an editable div where users can modify the content.</div>
// <span contenteditable="true">Users can type directly into this span to add or edit text.</span>
func ContentEditable(value string) html.Node {
return html.NewAttribute("contenteditable", value)
}
// Coords constructs an html.Node for the `coords` attribute.
//
// The `coords` attribute is used to specify the coordinates of
// specified shape in an image map. It is primarily used in the `area` element
// when defining clickable areas within an image. The `coords` attribute
// takes a comma-separated list of coordinates that define the shape and size
// of the clickable area. The exact format of the coordinates depends on the
// shape being used (e.g., rectangular, circular, or polygonal). The values
// represent percentage or pixel values relative to the dimensions of the
// image.
//
// Example Usage:
// <map name="image-map">
// <area shape="circle" coords="50,50,30" alt="Circle" href="circle.html">
// <area shape="rect" coords="10,10,100,100" alt="Rectangle" href="rectangle.html">
// <area shape="polygon" coords="10,10,100,10,100,100,10,100" alt="Polygon" href="polygon.html">
// </map>
// <img src="image.jpg" usemap="#image-map">
func Coords(value string) html.Node {
return html.NewAttribute("coords", value)
}
// CrossOrigin constructs an html.Node for the `crossorigin` attribute.
//
// `crossorigin` is used to specify how the browser should handle cross-origin
// resource requests when loading an external resource, such as a script or an
// image. This attribute provides a way to control whether the browser should
// send credentials, such as cookies or HTTP authentication, when making the
// request. The `crossorigin` attribute can have one of the following values:
// - "anonymous": The browser will not send any credentials with the request.
// - "use-credentials": The browser will send credentials with the request if
// the origin of the page and the resource being accessed have the same
// origin.
//
// Example Usage:
// <script src="https://example.com/script.js" crossorigin="anonymous"></script>
// <img src="https://example.com/image.jpg" crossorigin="use-credentials">
func CrossOrigin(value string) html.Node {
return html.NewAttribute("crossorigin", value)
}
// Data constructs an html.Node for the `data` attribute.
//
// `data` is a custom attribute that allows developers to store additional
// information within an HTML element. It is used to attach data to specific
// elements, providing a way to store metadata that is not visible or directly
// relevant to the presentation or behavior of the element. The value of the
// `data` attribute can be any valid string or JSON data, representing various
// types of information such as configuration settings, dynamic data, or
// customized data attributes.
//
// Example Usage:
// <div data-id="1234" data-category="electronics">This div stores data about a product.</div>
// <button data-action="submit-form" data-active="true">This button has data attributes to control its behavior.</button>
func Data(value string) html.Node {
return html.NewAttribute("data", value)
}
// DateTime constructs an html.Node for the `datetime` attribute.
//
// The `datetime` attribute is used to specify a machine-readable date and time
// value for an HTML element. It is primarily used for semantic markup and
// improving accessibility. The value of the `datetime` attribute should follow
// the ISO 8601 format, providing the date and time in a consistent and
// universal format. This attribute is commonly used in elements such as <time>
// to provide additional context and understanding of a specific date and time.
//
// Example Usage:
// <time datetime="2021-09-30T18:30:00Z">September 30, 2021 at 6:30 PM</time>
func DateTime(value string) html.Node {
return html.NewAttribute("datetime", value)
}
// Decoding constructs an html.Node for the `decoding` attribute.
//
// The `decoding` attribute is used in HTML to specify how the browser should
// decode and display media files. It allows developers to control how the video,
// audio, or image content is processed and presented to the user. The value of
// the `decoding` attribute can be set to "sync", "async", or "auto". When set to
// "sync", the browser will decode the media file synchronously, meaning it will
// process the file immediately. When set to "async", the browser will decode the
// media file asynchronously, meaning it will process the file in the background
// while the page is loading. Lastly, when set to "auto", the browser will
// determine the optimal decoding method based on the type of media and the user's
// device capabilities.
//
// Example Usage:
// <img src="image.jpg" decoding="auto">
// <video src="video.mp4" decoding="sync"></video>
// <audio src="audio.mp3" decoding="async"></audio>
func Decoding(value string) html.Node {
return html.NewAttribute("decoding", value)
}
// Dir constructs an html.Node for the `dir` attribute.
//
// `dir` is used to specify the text directionality for the content within an
// HTML element. It allows developers to control the ordering of text and the
// orientation of characters within the element. The `dir` attribute can have two
// possible values: "ltr" (left-to-right) for languages that read from left to
// right, and "rtl" (right-to-left) for languages that read from right to left.
//
// Example Usage:
// <p dir="ltr">This paragraph has left-to-right text direction.</p>
// <p dir="rtl">This paragraph has right-to-left text direction.</p>
func Dir(value string) html.Node {
return html.NewAttribute("dir", value)
}
// DirName constructs an html.Node for the `dirname` attribute.
//
// `dirname` is used to specify the text directionality of the content within
// an HTML element. It is primarily used for languages that are written from
// right-to-left, such as Arabic or Hebrew, to ensure that the text is rendered
// and displayed correctly. The value of the `dirname` attribute can be either
// `ltr` (left-to-right) or `rtl` (right-to-left), indicating the directionality
// of the text within the element.
//
// Example Usage:
// <p dirname="rtl">This paragraph contains right-to-left text.</p>
// <input type="text" dirname="ltr" placeholder="Enter your name">
func DirName(value string) html.Node {
return html.NewAttribute("dirname", value)
}
// Draggable constructs an html.Node for the `draggable` attribute.
//
// The `draggable` attribute is used to indicate whether an element can be
// dragged by the user. It can be applied to a wide range of HTML elements,
// including images, text, and divs. When set to `true`, the element can be
// dragged and dropped within the same page or between different applications or
// tabs. By default, all elements are not draggable unless the `draggable`
// attribute is explicitly set to `true`.
//
// Example Usage:
// <img src="image.jpg" draggable="true">
// <p draggable="false">This paragraph cannot be dragged by the user.</p>
func Draggable(value string) html.Node {
return html.NewAttribute("draggable", value)
}
// Enctype constructs an html.Node for the `enctype` attribute.
//
// `enctype` is used to specify how form data should be encoded and sent to the
// server when an HTML form is submitted. It is primarily used in the `<form>`
// element to control how the data is formatted and transmitted. The `enctype`
// attribute is especially important when the form contains file uploads, as it
// determines how the files will be encoded and sent.
//
// Example Usage:
// <form action="/submit" method="post" enctype="multipart/form-data">
// <input type="file" name="file">
// <input type="submit">
// </form>
func Enctype(value string) html.Node {
return html.NewAttribute("enctype", value)
}
// EnterKeyHint constructs an html.Node for the `enterkeyhint` attribute.
//
// The `enterkeyhint` attribute is used to provide a hint to the browser about the
// expected user action when the "Enter" key is pressed. It helps improve the
// user experience by suggesting the appropriate action, such as submitting a
// form, searching, or creating a new line. This attribute is particularly useful
// for input fields where the default behavior may not be ideal.
//
// Example Usage:
// <input type="text" enterkeyhint="search" placeholder="Search...">
// <input type="text" enterkeyhint="next" placeholder="Next item...">
// <input type="text" enterkeyhint="done" placeholder="Complete task...">
func EnterKeyHint(value string) html.Node {
return html.NewAttribute("enterkeyhint", value)
}
// FetchPriority constructs an html.Node for the `fetchpriority` attribute.
//
// The `fetchpriority` attribute is used to indicate the priority of fetching a
// resource in an HTML document. This attribute is typically used in the
// `<link>` or `<img>` tags to specify the importance of retrieving the
// resource. By setting a higher priority value for an element, browsers can
// prioritize fetching and rendering that element before others. This can help
// improve the perceived performance of a web page by ensuring that important
// resources are prioritized and loaded quickly.
//
// Example Usage:
// <link rel="stylesheet" href="styles.css" fetchpriority="high">
// <img src="image.jpg" fetchpriority="low">
func FetchPriority(value string) html.Node {
return html.NewAttribute("fetchpriority", value)
}
// For constructs an html.Node for the `for` attribute.
//
// The `for` attribute is used to create a relationship between a label element
// and another element on the web page. It is primarily used to associate a label
// with a form input element, allowing users to click on the label to activate
// the corresponding input. This improves accessibility and usability by
// increasing the clickable area of the input. The value of the `for` attribute
// should match the `id` attribute of the related element.
//
// Example Usage:
// <label for="name">Name:</label>
// <input type="text" id="name" name="name" placeholder="Enter your name">
func For(value string) html.Node {
return html.NewAttribute("for", value)
}
// Form constructs an html.Node for the `form` attribute.
//
// The `form` attribute is used to associate an HTML element with a specific
// form. It allows input elements, such as buttons or text fields, to be
// grouped together and submitted as a single form. When the form is submitted,
// the input values from all associated elements are sent to the server.
//
// Example Usage:
// <input type="text" form="myForm" placeholder="Enter your name">
// <button type="submit" form="myForm">Submit</button>
func Form(value string) html.Node {
return html.NewAttribute("form", value)
}
// FormAction constructs an html.Node for the `formaction` attribute.
//
// `formaction` is used to override the default submission URL of a form when
// the submit button is clicked. It allows developers to specify a different URL
// that will receive the form data upon submission. This attribute is typically
// used in conjunction with the `form` and `input` elements to control the
// behavior of form submission.
//
// Example Usage:
// <input type="submit" formaction="/submit-form">
func FormAction(value string) html.Node {
return html.NewAttribute("formaction", value)
}
// FormEncType constructs an html.Node for the `formenctype` attribute.
//
// `formenctype` is used to specify the encoding type to be used when submitting
// data from an HTML form to the server. It allows developers to indicate whether
// the data should be encoded as `application/x-www-form-urlencoded` (the default)
// or as `multipart/form-data`. The `application/x-www-form-urlencoded` encoding
// is used for sending simple form data, while the `multipart/form-data` encoding
// is used for sending file uploads or binary data. The value of the `formenctype`
// attribute should be set to either `application/x-www-form-urlencoded` or
// `multipart/form-data`.
//
// Example Usage:
// <form method="post" action="/submit" formenctype="multipart/form-data">
// <input type="file" name="myfile">
// <input type="submit" value="Submit">
// </form>
func FormEncType(value string) html.Node {
return html.NewAttribute("formenctype", value)
}
// FormMethod constructs an html.Node for the `formmethod` attribute.
//
// `formmethod` is used to specify the HTTP method to be used when submitting
// a form in an HTML document. This attribute is applied to the `button` or
// `input` elements with a `type` of "submit" or "image". The `formmethod`
// attribute allows developers to override the default method (which is usually
// "GET") and specify a different method such as "POST". This is especially
// useful when submitting sensitive information or when the form data modifies
// server-side resources. The value of the `formmethod` attribute should be a
// valid HTTP method, such as "GET" or "POST".
//
// Example Usage:
// <button formmethod="POST" type="submit">Submit Form</button>
// <input formmethod="DELETE" type="submit" value="Delete Item">
func FormMethod(value string) html.Node {
return html.NewAttribute("formmethod", value)
}
// FormTarget constructs an html.Node for the `formtarget` attribute.
//
// `formtarget` is used to specify where the form data should be submitted when
// the user submits a form. It overrides the default behavior of submitting the
// form to the same page. The value of the `formtarget` attribute can be a URL
// or one of the following keywords:
//
// - `_blank`: Opens the form response in a new tab or window.
// - `_self`: Loads the form response in the same frame or window.
// - `_parent`: Loads the form response in the parent frame or window.
// - `_top`: Loads the form response in the full body of the window.
//
// Example Usage:
// <form action="/submit" method="post" target="_blank">
// <input type="text" name="name">
// <input type="submit" value="Submit">
// </form>
func FormTarget(value string) html.Node {
return html.NewAttribute("formtarget", value)
}
// Headers constructs an html.Node for the `headers` attribute.
//
// The `headers` attribute is used to establish a relationship between a data
// cell (`<td>`) and its corresponding header cell (`<th>`) in an HTML table.
// It defines a space-separated list of header cell IDs that the data cell is
// associated with. This allows assistive technologies, such as screen readers,
// to correctly interpret and present tabular data to users with disabilities.
//
// Example Usage:
// <table>
// <tr>
// <th id="name">Name</th>
// <th id="age">Age</th>
// </tr>
// <tr>
// <td headers="name">John Doe</td>
// <td headers="age">25</td>
// </tr>
// </table>
func Headers(value string) html.Node {
return html.NewAttribute("headers", value)
}
// Height constructs an html.Node for the `height` attribute.
//
// The `height` attribute is used to specify the height of an HTML element. It
// determines the vertical size of the element and can be applied to various
// types of elements such as images, tables, divs, and iframes. The value of
// the `height` attribute can be specified in pixels, percentages, or other CSS
// length units. It allows developers to control the visual layout of elements
// and ensure consistency in the presentation of the web page.
//
// Example Usage:
// <img src="image.jpg" alt="An image" height="200">
// <div style="height: 300px;">This div has a fixed height of 300 pixels.</div>
func Height(value string) html.Node {
return html.NewAttribute("height", value)
}
// High constructs an html.Node for the `high` attribute.
//
// The `high` attribute is used to specify a numerical value that represents
// the importance or priority of an HTML element. It is primarily used in
// ordered lists (ol) to indicate the level of importance for each list item.
// The value of the `high` attribute should be an integer, with a higher value
// indicating a higher level of importance. This attribute is often used in
// conjunction with CSS to style the list items based on their importance.
//
// Example Usage:
// <ol>
// <li high="3">This is the most important item</li>
// <li high="2">This is a moderately important item</li>
// <li high="1">This is the least important item</li>
// </ol>
func High(value string) html.Node {
return html.NewAttribute("high", value)
}
// HRef constructs an html.Node for the `href` attribute.
//
// The `href` attribute is used to specify the URL of a linked resource in an
// HTML document. It enables the creation of hyperlinks, allowing users to
// navigate between different pages or sections of a website. The value of the
// `href` attribute acts as the address that the hyperlink points to. When
// clicked, the browser will navigate to the URL specified by the `href`
// attribute value, loading the corresponding webpage. The value can be an
// absolute or relative URL, allowing links to external sites or different
// sections within the same site.
//
// Example Usage:
// <a href="https://www.example.com">This link directs to an external website.</a>
// <a href="/about">This link directs to the 'about' page within the same website.</a>
func HRef(value string) html.Node {
return html.NewAttribute("href", value)
}
// HRefLang constructs an html.Node for the `hreflang` attribute.
//
// `hreflang` is used to specify the language of the linked resource in an HTML
// document. It is primarily used in anchor (a) tags to provide information
// about the language of the target webpage. This attribute helps search
// engines understand the language of the linked page, allowing them to display
// the correct version of the webpage to users who speak the same language. The
// value of the `hreflang` attribute should be a language code, following the
// ISO 639-1 or ISO 639-2 standards.
//
// Example Usage:
// <a href="https://www.example.com" hreflang="en">This link directs to an English version of the website.</a>
// <a href="https://www.example.es" hreflang="es">Este enlace dirige a la versión en español del sitio web.</a>
func HRefLang(value string) html.Node {
return html.NewAttribute("hreflang", value)
}
// HttpEquiv constructs an html.Node for the `http-equiv` attribute.
//
// `http-equiv` is used to provide an HTTP header for an HTML document.
// It allows developers to specify information about the document's content type,
// refresh rate, character encoding, and other important metadata that affects
// how the document is interpreted and displayed by the browser. The value of the
// `http-equiv` attribute is a string that corresponds to a specific HTTP header
// field, such as "Content-Type" or "Refresh". This attribute is commonly used in
// legacy HTML documents or in situations where server-side headers cannot be
// modified directly.
//
// Example Usage:
// <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
// <meta http-equiv="Refresh" content="5; URL=https://www.example.com">
func HttpEquiv(value string) html.Node {
return html.NewAttribute("http-equiv", value)
}
// Id constructs an html.Node for the `id` attribute.
//
// The `id` attribute is used to uniquely identify an HTML element. It allows
// developers to reference and target specific elements in CSS and JavaScript.
// The value of the `id` attribute should be unique within the HTML document.
//
// Example Usage:
// <div id="header">This div represents the header section of the webpage.</div>
// <button id="submitBtn">This button triggers a form submission.</button>
func Id(value string) html.Node {
return html.NewAttribute("id", value)
}
// ImageSizes constructs an html.Node for the `imagesizes` attribute.
//
// `imagesizes` is used to specify the sizes of the available image sources in
// an HTML document. It helps browsers select the appropriate image source
// based on the device's screen size and resolution, improving performance and
// optimizing the display of images. The value of the `imagesizes` attribute is
// a space-separated list of image widths, allowing developers to provide
// multiple sizes for different screen sizes and resolutions.
//
// Example Usage:
// <img src="image.jpg" alt="Example" imagesizes="320px, 640px, 960px">
// <img srcset="image_small.jpg 320w, image_medium.jpg 640w, image_large.jpg 960w" sizes="(max-width: 600px) 320px, (max-width: 1200px) 640px, 960px" alt="Example">
func ImageSizes(value string) html.Node {
return html.NewAttribute("imagesizes", value)
}
// ImageSrcSet constructs an html.Node for the `imagesrcset` attribute.
//
// `imagesrcset` is used to specify multiple sources for an image in an HTML
// document. This attribute allows the browser to choose the most appropriate
// image source based on factors like screen resolution or device capabilities.
// The `imagesrcset` attribute is typically used in conjunction with the `src`
// attribute to provide alternative image sources for different scenarios. Each
// source in the `imagesrcset` attribute is defined with a URL and a descriptor
// that specifies the image's width or pixel density. The browser selects the
// source that best matches the conditions and loads that image.
//
// Example Usage:
// <img src="small.jpg" imagesrcset="medium.jpg 800w, large.jpg 1200w">
func ImageSrcSet(value string) html.Node {
return html.NewAttribute("imagesrcset", value)
}
// InputMode constructs an html.Node for the `inputmode` attribute.
//
// `inputmode` is used to specify the expected input method for an HTML input
// element. It helps optimize the user experience by suggesting the appropriate
// on-screen keyboard layout or input method based on the expected input type.
// By using the `inputmode` attribute, developers can provide better input
// suggestions, autocorrect, and validation for user input. The value of the
// `inputmode` attribute can be set to various values such as "numeric",
// "tel", "email", "url", "search", etc., depending on the type of input expected.
//
// Example Usage:
// <input type="text" inputmode="numeric" placeholder="Enter a number">
// <input type="tel" inputmode="tel" placeholder="Enter a phone number">
// <input type="email" inputmode="email" placeholder="Enter an email address">
func InputMode(value string) html.Node {
return html.NewAttribute("inputmode", value)
}
// Integrity constructs an html.Node for the `integrity` attribute.
//
// The `integrity` attribute is used to ensure the authenticity and integrity
// of a linked resource in an HTML document. It allows developers to include a
// cryptographic hash value, such as an SHA-256 hash, which is used to verify
// that the resource has not been tampered with or altered. This is
// particularly important for resources like scripts or stylesheets that are
// served from external sources.
//
// Example Usage:
// <script src="https://example.com/script.js" integrity="sha256-ABC123DEF456GHI789"></script>
func Integrity(value string) html.Node {
return html.NewAttribute("integrity", value)
}
// Is constructs an html.Node for the `is` attribute.
//
// The `is` attribute is used to apply a custom element or behavior to an HTML
// element. It allows developers to define their own custom elements and extend
// the functionality of existing HTML elements. By specifying the value of the
// `is` attribute as the name of a custom element, the HTML element is
// transformed into the custom element with its associated behaviors.
//
// Example Usage:
// <button is="custom-button">This button has custom functionality applied to it.</button>
func Is(value string) html.Node {
return html.NewAttribute("is", value)
}
// ItemId constructs an html.Node for the `itemid` attribute.
//
// `itemid` is used to specify a unique identifier for an item in an HTML
// document. It is primarily used in conjunction with structured data markup,
// such as the schema.org vocabulary, to provide additional information about the
// item. The `itemid` attribute enables search engines and other applications to
// identify and index specific items on a webpage, improving the visibility and
// understanding of the content.
//
// Example Usage:
// <div itemscope itemtype="http://schema.org/Book">
// <span itemprop="name">The Catcher in the Rye</span>
// <link itemprop="url" href="https://www.example.com/books/catcher-in-the-rye">
// </div>
func ItemId(value string) html.Node {
return html.NewAttribute("itemid", value)
}
// ItemProp constructs an html.Node for the `itemprop` attribute.
//
// `itemprop` is used to specify a specific property or attribute of an HTML
// element that is part of a structured data set. It is primarily used for
// creating semantic markup and providing context to search engines about the
// content of the element. By using `itemprop`, developers can enhance the
// meaning and relevance of their content for search engine optimization (SEO)
// purposes. The value of the `itemprop` attribute typically corresponds to a
// specific schema.org property, such as "name" or "description".
//
// Example Usage:
// <span itemprop="name">Product Name</span>
// <img itemprop="image" src="product.jpg" alt="Product Image">
func ItemProp(value string) html.Node {
return html.NewAttribute("itemprop", value)
}
// ItemRef constructs an html.Node for the `itemref` attribute.
//
// The `itemref` attribute is used to create associations between elements in
// an HTML document. It is primarily used in HTML microdata to specify
// additional elements that contain properties related to a main element. By
// referencing the IDs of other elements using the `itemref` attribute, the
// properties from those elements can be included in the main element's
// microdata.
//
// Example Usage:
// <div id="item1" itemscope itemtype="http://schema.org/Book"></div>
// <div id="item2" itemscope itemtype="http://schema.org/Person"></div>
// <div id="mainItem" itemscope itemtype="http://schema.org/Review" itemref="item1 item2"></div>
func ItemRef(value string) html.Node {
return html.NewAttribute("itemref", value)
}
// ItemType constructs an html.Node for the `itemtype` attribute.
//
// `itemtype` is used to specify the type of an item in an HTML document using a
// URL. It is primarily used in conjunction with the `itemscope` attribute to
// create structured data markup using the Schema.org vocabulary. The value of the
// `itemtype` attribute is a URL that identifies the type of the item, providing
// contextual information about its meaning and properties. This attribute helps
// search engines and other applications understand the content and its
// relationships, contributing to improved search results and enhanced
// presentation of the data.
//
// Example Usage:
// <div itemscope itemtype="http://schema.org/Person">
// <span itemprop="name">John Doe</span>
// <span itemprop="jobTitle">Web Developer</span>
// </div>
func ItemType(value string) html.Node {
return html.NewAttribute("itemtype", value)
}
// Kind constructs an html.Node for the `kind` attribute.
//
// The `kind` attribute is used to specify the type or category of a media
// resource in an HTML document. It is primarily used in the `<source>` element
// within `<video>` or `<audio>` tags to provide alternative media sources. The
// `kind` attribute allows developers to differentiate between different
// formats or qualities of the media file, such as captions, subtitles, or
// alternative audio tracks. By specifying the `kind` attribute, the browser
// can determine which media source to use based on the user's preferences or
// accessibility requirements.
//
// Example Usage:
// <video>
// <source src="video.mp4" type="video/mp4" kind="main">
// <source src="video.webm" type="video/webm" kind="alternative">
// <track src="video.vtt" kind="captions" srclang="en" label="English">
// </video>
func Kind(value string) html.Node {
return html.NewAttribute("kind", value)
}
// Label constructs an html.Node for the `label` attribute.
//
// The `label` attribute is used to associate text with form elements in an HTML
// document. It helps improve accessibility by providing a textual description or
// name for the form element, making it easier for users to understand the purpose
// or function of the element. The `label` attribute is usually used in conjunction
// with the `for` attribute, which specifies which form element the label is
// associated with. This allows users to click on the label to activate the
// associated form element, enhancing usability.
//
// Example Usage:
// <label for="username">Username:</label>
func Label(value string) html.Node {
return html.NewAttribute("label", value)
}
// Lang constructs an html.Node for the `lang` attribute.
//
// `lang` is used to specify the language of the text contained within an
// element. It allows developers to indicate the language of the content to
// support accessibility and SEO purposes. The value of the `lang` attribute
// should be a valid language code defined by the W3C, such as "en" for English
// or "ja" for Japanese.
//
// Example Usage:
// <p lang="fr">Ce paragraphe est écrit en français.</p>
// <span lang="es">Este texto está en español.</span>
func Lang(value string) html.Node {
return html.NewAttribute("lang", value)
}
// List constructs an html.Node for the `list` attribute.
//
// The `list` attribute is used to associate an input element with a datalist
// element. It allows for autocomplete functionality, where the user can choose
// from a predefined set of options while typing in the input field. The `list`
// attribute's value should be equal to the `id` attribute of the datalist
// element it is associated with. When the user types in the input field, a
// dropdown list of options will appear based on the values specified in the
// associated datalist element. The user can select an option from the
// dropdown, and the selected value will be filled in the input field.
//
// Example Usage:
// <input type="text" list="fruits">
// <datalist id="fruits">
// <option value="Apple">
// <option value="Banana">
// <option value="Orange">
// </datalist>
func List(value string) html.Node {
return html.NewAttribute("list", value)
}
// Loading constructs an html.Node for the `loading` attribute.
//
// The `loading` attribute is used to control the loading behavior of external
// resources, such as images or scripts, in an HTML document. It determines
// when and how these resources are loaded, allowing developers to optimize
// page loading speed and improve user experience.
//
// Example Usage:
// <img src="image.jpg" loading="lazy">
// <script src="script.js" loading="defer"></script>
func Loading(value string) html.Node {
return html.NewAttribute("loading", value)
}
// Low constructs an html.Node for the `low` attribute.
//
// The `low` attribute is used to indicate the lower bound value of a range in
// an HTML input element. It is primarily used with the `input` element to
// define the minimum value that can be selected or entered by the user. This
// attribute ensures that the user does not enter a value below the specified
// lower bound.
//
// Example Usage:
// <input type="number" low="0" max="100">
// This input field allows the user to enter a number between 0 and 100,
// inclusive, with 0 being the minimum value.
func Low(value string) html.Node {
return html.NewAttribute("low", value)
}
// Max constructs an html.Node for the `max` attribute.