html★ intelligently infers request URLs and methods from standard HTML attributes.
URL Inference
html★ gets the request URL from standard HTML attributes:
| Element | URL Source | Example |
|---|---|---|
<a> | href | <a href="/users"> |
<form> | action | <form action="/submit"> |
<button> in form | formaction | <button formaction="/save"> |
| Any element | data-href | <div data-href="/api/data"> |
Priority: data-href > href > action > formaction
Method Inference
The HTTP method is inferred similarly:
| Element | Method Source | Default |
|---|---|---|
<a> | (implicit) | GET |
<form> | method | GET |
<button> in form | formmethod | Form's method |
| Any element | data-method | GET |
Examples
Links (GET by default)
HTML
<!-- Uses href, method is GET --><a href="/users" data-target="#main">View Users</a>
Forms
HTML
<!-- Uses action and method --><form action="/users" method="post" data-target="#result"> <input name="email" type="email"> <button>Submit</button></form>
Custom Methods
HTML
<!-- DELETE request --><button data-href="/users/123" data-method="delete" data-target="#user-row" data-swap="delete"> Delete User</button>
Non-Link Elements
HTML
<!-- Any element can make requests --><div data-href="/api/status" data-trigger="load" data-target="self"> Loading status...</div>
Skip Rules
html★ automatically skips certain elements:
| Condition | Example | Reason |
|---|---|---|
| External URL | href="https://other.com" | Different origin |
| Anchor link | href="#section" | In-page navigation |
| Download | <a download> | File download |
| New window | target="_blank" | Opens new window |
| Opt-out | data-target="" | Explicitly disabled |
Why Inference? By using standard HTML attributes, your markup stays clean and valid. Links work without JavaScript, and html★ enhances them when available. No need for redundant
data-urlattributes whenhrefalready exists!