عناصر <h1>
–<h6>
تقدم لنا سته مستويات من عناوين الأقسام. حيث أن العنصر<h1>
يمثل العنوان الأعلى مستوى في الأهمية بينما العنصر <h2>
هو الأقل.
فئات المحتوى | Flow content, heading content, palpable content. |
---|---|
المحتوى المسموح به | Phrasing content. |
إغفال الوسوم | لا شئ، كلاً من وسمّي الفتح والإقفال إجباري |
الأباء المسموح بهم للعنصر | Any element that accepts flow content; don't use an heading element as a child of the <hgroup> element — it is now deprecated. |
Permitted ARIA roles | tab , presentation |
DOM interface | HTMLHeadingElement |
السمات
هذه العناصر تتضمن السمات العامة.
السمة align
عفاء عنها الزمن، لا تستخدمها
ملاحظات الإستخدام
- يمكن إستخدام معلومات العناوين من قبل الـ user agents, على سبيل المثال لإنشاء جدول المحتويات لمستند بشكل تلقائي.
- لا تستخدم عناوين بمستويات منخفضة لتقليل حجم خط العناوين: إستخدم خاصية لغة CSS المسؤولة عن التحكم بأحجام الخطوط font-size بدلاً من ذلك.
- تجنب تخطي مستويات العناوين: دائماً إبدا من
<h1>
، من ثم إستخدم<h2>
وهكذا. - يجب أن تأخذ بعين الإعتبار تجنب إستخدام العنصر <h1> أكثر من مرة في الصفحة. إطلع على تعريف الأقسام في إستخدام الأقسام و وتسلسل العناوين في الـ HTML لمعلومات أكثر.
أمثلة
جميع العناوين
الكود التالي يظهر كل مستويات العناوين، قيد الإستخدام.
<h1>Heading level 1</h1>
<h2>Heading level 2</h2>
<h3>Heading level 3</h3>
<h4>Heading level 4</h4>
<h5>Heading level 5</h5>
<h6>Heading level 6</h6>
هنا نتيجة هذا الكود:
مثال لصفحة
الكود التالي يظهر بعض العناوين مع بعض المحتوى بأسفلها.
<h1>Heading elements</h1>
<h2>Summary</h2>
<p>Some text here...</p>
<h2>Examples</h2>
<h3>Example 1</h3>
<p>Some text here...</p>
<h3>Example 2</h3>
<p>Some text here...</p>
<h2>See also</h2>
<p>Some text here...</p>
هنا نتيجة هذا الكود:
سهولة الوصول
التنقل بين الأجزاء والصفحات
من الأساليب الشائعة للتنقل بين أجزاء الصفحة من قبل مستخدمي قارئات الشاشات هو القفز من عنوان لأخر لتحديد محتوى الصفحة بشكل سريع.
لهذا السبب، من المهم عدم تخطي أحد مستويات العناوين فالقيام بذلك قد يسبب ارتباك للشخص الذي يقوم بالتنقل بين أجزاء الموقع بهذه الطريقة وربما يترك لدية نوع من الحيرة عن أين هو العنوان المفقود.
لا تقم بالتالي:
<h1>Heading level 1</h1>
<h3>Heading level 3</h3>
<h4>Heading level 4</h4>
قم بالتالي:
<h1>Heading level 1</h1>
<h2>Heading level 2</h2>
<h3>Heading level 3</h3>
تسلسل العناوين - Nesting
قد يتم عمل تسلسل لبعض العناوين لتبدو كعناوين أقسام فرعية لعكس تنظيم محتوى الصفحة. أغلب قارئات الشاشات تستطيع أيضا تكوين قائمة مرتبة لكل العناوين التي في الصفحة، ما قد يساعد الشخص لتحديد التسلسل الهرمي للمحتوى بسرعة :
h1
Beetlesh2
Etymologyh2
Distribution and Diversityh2
Evolutionh3
Late Paleozoich3
Jurassich3
Cretaceoush3
Cenozoic
h2
External Morphologyh3
Headh4
Mouthparts
h3
Thoraxh4
Prothoraxh4
Pterothorax
h3
Legsh3
Wingsh3
Abdomen
When headings are nested, heading levels may be "skipped" when closing a subsection.
- Headings • Page Structure • WAI Web Accessibility Tutorials
- MDN Understanding WCAG, Guideline 1.3 explanations
- Understanding Success Criterion 1.3.1 | W3C Understanding WCAG 2.0
- MDN Understanding WCAG, Guideline 2.4 explanations
- Understanding Success Criterion 2.4.1 | W3C Understanding WCAG 2.0
- Understanding Success Criterion 2.4.6 | W3C Understanding WCAG 2.0
- Understanding Success Criterion 2.4.10 | W3C Understanding WCAG 2.0
Labeling section content
Another common navigation technique for users of screen reading software is to generate a list of sectioning content and use it to determine the page's layout.
Sectioning content can be labeled using a combination of the aria-labelledby
and id
attributes, with the label concisely describing the purpose of the section. This technique is useful for situations where there is more than one sectioning element on the same page.
Example
<header>
<nav aria-labelledby="primary-navigation">
<h2 id="primary-navigation">Primary navigation</h2>
<!-- navigation items -->
</nav>
</header>
<!-- page content -->
<footer>
<nav aria-labelledby="footer-navigation">
<h2 id="footer-navigation">Footer navigation</h2>
<!-- navigation items -->
</nav>
</footer>
In this example, screen reading technology would announce that there are two <nav>
sections, one called "Primary navigation" and one called "Footer navigation". If labels were not provided, the person using screen reading software may have to investigate each nav
element's contents to determine their purpose.
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of '<h1>, <h2>, <h3>, <h4>, <h5>, and <h6>' in that specification. |
Living Standard | |
HTML5 The definition of '<h1>, <h2>, <h3>, <h4>, <h5>, and <h6>' in that specification. |
Recommendation | |
HTML 4.01 Specification The definition of '<h1>, <h2>, <h3>, <h4>, <h5>, and <h6>' in that specification. |
Recommendation |
Browser compatibility
BCD tables only load in the browser