1+ <!doctype html>
2+ < html lang ="en ">
3+ < head >
4+ < meta charset ="utf-8 ">
5+ < meta name ="viewport " content ="width=device-width, initial-scale=1 ">
6+ < title >
7+ Using The Button Form Attribute To Create Standalone Buttons In HTML
8+ </ title >
9+ < link rel ="stylesheet " type ="text/css " href ="./main.css ">
10+ </ head >
11+ < body >
12+
13+ < h1 >
14+ Using The Button Form Attribute To Create Standalone Buttons In HTML
15+ </ h1 >
16+
17+ < nav class ="nav ">
18+ < a href ="index.htm?nav=home " class ="nav__item ">
19+ Home
20+ </ a >
21+ < a href ="index.htm?nav=about " class ="nav__item ">
22+ About
23+ </ a >
24+ < a href ="index.htm?nav=projects " class ="nav__item ">
25+ Projects
26+ </ a >
27+ <!--
28+ But letting the button stand on its own, we can STYLE it in the same way that
29+ we do the sibling link elements. Meaning, we don't have to worry about dealing
30+ with an extra form wrapper, or use janky techniques like "display:contents".
31+ -->
32+ < button type ="submit " form ="logOutForm " class ="nav__item link-button ">
33+ Log-Out
34+ </ button >
35+ </ nav >
36+
37+ <!--
38+ This form has no inherent action, it's basically just a "data bag". It only gets
39+ triggered when the button above is clicked. The button's [FORM] attribute makes
40+ it the submit trigger for this form.
41+
42+ Note: normally, this would be a [POST] action; however, in order to make this demo
43+ work on GitHub Pages, I'm using a [GET].
44+ -->
45+ < form id ="logOutForm " method ="get " action ="index.htm ">
46+ < input type ="hidden " name ="action " value ="logout " />
47+ < input type ="hidden " name ="submitted " value ="true " />
48+ < input type ="hidden " name ="xsrfToken " value ="abc123 " />
49+ < input type ="hidden " name ="userID " value ="10011 " />
50+ </ form >
51+
52+ < p >
53+ < a href ="./index2.htm "> See Demo 2</ a >
54+ </ p >
55+
56+ </ body >
57+ </ html >
0 commit comments