├── .gitmodules ├── LICENSE ├── README.md ├── demo-fallback.html ├── demo.css ├── fallback └── html5-h.html ├── generate-fallback.sh ├── heading-spec └── index.html ├── html5-h.html └── index.html /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "components/platform"] 2 | path = components/platform 3 | url = https://github.com/Polymer/platform.git 4 | [submodule "components/polymer"] 5 | path = components/polymer 6 | url = https://github.com/Polymer/polymer.git 7 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 The Paciello Group 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | `` 2 | ============ 3 | 4 | Custom heading element intended to replace `

` to `

` with a single heading element (yup just like [XHTML promised land](https://www.w3.org/TR/xhtml2/mod-structural.html#sec_8.5.)) and the [promise of the HTML5 outline](https://www.tpgi.com/html5-document-outline/). 5 | 6 | Try the [demo page](https://thepaciellogroup.github.io/html5-h/). 7 | 8 | What it does 9 | ------------- 10 | 11 | When a `` element is used, the element is automatically styled as per [HTML5 UA style sheet](http://www.w3.org/html/wg/drafts/html/master/rendering.html#sections-and-headings) advice, is given an ARIA [role=heading](http://www.w3.org/TR/wai-aria/roles#heading), and `level` and [aria-level](http://www.w3.org/TR/wai-aria/states_and_properties#aria-level) attributes to reflect its HTML5 [document outline depth](http://www.w3.org/html/wg/drafts/html/master/sections.html#outline-depth). 12 | 13 | This means that it works out its heading level automatically and is accessible to people who use Assistive Technologies (ATs) "out of the box". 14 | 15 | This can be seen in action by viewing the [demo page](https://thepaciellogroup.github.io/html5-h/) source code (using "View Page Source") and generated code (using DOM inspection tools). 16 | 17 | ### HTML 18 | 19 | Your source code: 20 | 21 | ```html 22 | . . . 23 | 24 | 25 | Main Heading 26 |
27 | 28 | Sub-heading 29 | . . . 30 | ``` 31 | 32 | Generated code: 33 | 34 | ```html 35 | . . . 36 | 37 | Main Heading 38 |
39 | Sub-heading 40 | . . . 41 | ``` 42 | 43 | By default, the first `` is styled as if it were a `

` and the second `` element is styled as if it were a `

`. 44 | 45 | ### Styling 46 | 47 | The way we style `

` to `

` elements: 48 | 49 | ```css 50 | h1 { ... } 51 | h2 { ... } 52 | ``` 53 | 54 | The `` equivalent: 55 | 56 | ```css 57 | html5-h[level="1"] { ... } /* all level 1 s */ 58 | html5-h[level="2"] { ... } /* all level 2 s */ 59 | ``` 60 | 61 | The `level` attribute (set automatically for you) allows `` to be used by people with no knowledge of [aria-level](http://www.w3.org/TR/wai-aria/states_and_properties#aria-level) (though `aria-level` can be used for this also). 62 | 63 | You can also style according to how it is nested within elements (this ties the styling to the exact document structure, rather than heading level): 64 | 65 | ```css 66 | html5-h { ... } /* level 1 */ 67 | section html5-h { ... } /* level 2 */ 68 | section section html5-h { ... } /* level 3 */ 69 | article section html5-h { ... } /* a different level 3 */ 70 | ``` 71 | 72 | ### Manually specifiying a heading level 73 | 74 | If you are using `` with HTML5 [sectioning content](https://www.w3.org/TR/html5/dom.html#sectioning-content) (as above) it is **strongly recommended to *not* manually set the `level` attribute**, as the level will be computed for you. 75 | 76 | If you do manually set the `level` attribute in your HTML (to a non-zero positive integer, e.g. "4" or "2") then the `` will take that level (and that level will be reported to Assistive Technologies (ATs)). You would need to do this when making use of `` outside of HTML5 [sectioning content](https://www.w3.org/TR/html5/dom.html#sectioning-content) (e.g. if you are using nested `
`s instead of those sectioning elements). 77 | 78 | You may also want to read our [micro-spec for how the `level` attribute behaves](https://github.com/ThePacielloGroup/html5-h/issues/16). 79 | 80 | ### Stand-alone and fallback versions 81 | 82 | We recommend using the stand-alone `` element described above, as long as: 83 | 84 | * You are using HTML5 and doing sectioning entirely with HTML5 [sectioning content](https://www.w3.org/TR/html5/dom.html#sectioning-content). 85 | * JavaScript will be available. 86 | 87 | Even if you're not using HTML5 sectioning elements exclusively, you can still use the stand-alone ``, but you'll need to set the `level` attribute manually for headings outside of HTML5 sectioning elements. (Note that you can ignore `
` elements, as they're not considered sectioning contnet the automatically-computed level will still be correct.) 88 | 89 | Alternatively, or if JavaScript may be unavailable, you should consider using the fallback version of `` that extends `

` instead. 90 | 91 | Using the fallback has the advantage that a genuine heading element will be apparent in the browser, even when JavaScript is unavailable. However, all headings will be `

`s, so accessibility wouldn't be ideal---but would be better than no headings at all. 92 | 93 | Both the stand-alone and fallback versions can be used directly from this repository. The `generate-fallback.sh` script is simply a development tool that can be run on UNIX systems to update the fallback version's code when the stand-alone code changes. 94 | 95 | There is a [demo page for the fallback version](https://thepaciellogroup.github.io/html5-h/demo-fallback.html). 96 | 97 | Development status 98 | ------------------- 99 | 100 | Currently done: 101 | 102 | * Implemented styling (heading size based on `
`/`