Skip to content

Commit f039186

Browse files
tonystaranton-staroverov
authored andcommitted
Update README.md
Fixes #10: Add a notes about label reverse order and "for" attr
1 parent c3353a8 commit f039186

File tree

1 file changed

+29
-13
lines changed

1 file changed

+29
-13
lines changed

README.md

Lines changed: 29 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,20 @@ Pure-CSS Float Label. Finally.
88

99
Bulletproof CSS-only implementation of Float Label pattern with automatic fallback for ANY non-supporting browser.
1010

11-
* No JS!
11+
* No JS! Pure CSS!
1212
* No hacks with `required` and `:valid`!
13-
* => HTML5 validation support
14-
* => `<select>` fields support
13+
* ↳ HTML5 validation support!
14+
* Compatible with `<select>` fields!
15+
* No need to define `for="..."` attribute on `<label>`! <sup>**v1.0.1+**</sup>
1516

1617
<img src="https://cdn.rawgit.com/tonystar/float-label-css/9dd8582/float-label-css.gif" width="400"/>
1718

1819

1920
## Demo
2021

21-
No-dependencies demo: https://codepen.io/tonystar/pen/JRLaKw.
22-
23-
Bootstrap 3 demo: https://codepen.io/tonystar/pen/ALaZrV.
24-
25-
Bootstrap 4 demo: https://codepen.io/tonystar/pen/LRdpYZ.
22+
* [No-dependencies demo](https://codepen.io/tonystar/pen/JRLaKw)
23+
* [Bootstrap 3 demo](https://codepen.io/tonystar/pen/ALaZrV)
24+
* [Bootstrap 4 demo](https://codepen.io/tonystar/pen/LRdpYZ)
2625

2726

2827
## Usage
@@ -32,15 +31,32 @@ Include `float-label.min.css`:
3231
<link rel="stylesheet" href="https://cdn.rawgit.com/tonystar/float-label-css/v1.0.0/dist/float-label.min.css"/>
3332
```
3433

35-
Wrap `input` and `label` by `.has-float-label`:
34+
Use `<label>` with `.float-label` class as a wrapper for `<input>` <sup>**v1.0.1+**</sup>:
35+
```html
36+
<label class="float-label">
37+
<input type="email" placeholder="[email protected]"/>
38+
<span>Email</span>
39+
</label>
40+
```
41+
**NOTE**:
42+
43+
1. W3C [allows this](http://www.w3.org/TR/html401/interact/forms.html#edef-LABEL).
44+
2. `<span>` should go after `<input>`.
45+
46+
***
47+
48+
Alternatively wrap `<input>` and `<label>` by `.has-float-label`:
3649
```html
37-
<span class="has-float-label">
38-
<input class="form-control" id="email" type="email" placeholder="box@example.com"/>
50+
<div class="has-float-label">
51+
<input id="email" type="email" placeholder="email@example.com"/>
3952
<label for="email">Email</label>
40-
</span>
53+
</div>
4154
```
55+
**NOTE**:
4256

43-
**NOTE:** `label` should go after `input`! This is the only drawback in this method.
57+
1. W3C [allows this](http://www.w3.org/TR/html401/interact/forms.html#edef-LABEL) as well.
58+
2. `<label>` should go after `<input>`.
59+
3. `for="..."` attribute is required on `<label>`.
4460

4561

4662
### Quick use: Bootstrap

0 commit comments

Comments
 (0)