النمط المضاد للمرساة التي بلا href
تعرّف إلى سبب تعطيل الرابط الوهمي لمستخدمي لوحة المفاتيح وقارئات الشاشة.
النمط المضاد للمرساة التي بلا href درس مجاني في Web Accessibility Academy على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Web Accessibility Academy، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Web Accessibility Academy 4 دروس في المجموع.
بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.
The Fake Link
A common anti-pattern is an anchor with no href, wired up with a click handler to act like a button. It looks fine but breaks things.
<a onclick="openMenu()">Menu</a>No href, No Link
An anchor only counts as a real link when it has an href. Without one, the browser does not treat it as interactive at all.
It Falls Out of Tab Order
An href-less anchor is not focusable, so keyboard users tabbing through the page skip right past it and can never reach it.
The Keyboard Cannot Fire It
Even if you force focus onto it, a fake link ignores Enter and Space by default, so keyboard users still cannot activate it.
Screen Readers Get Confused
Without an href, a screen reader may not announce the anchor as a link at all, so users never learn it is something they can use.
The href Pound Hack
Some patch it with an href of just a hash. That makes it focusable but it also jumps the page to the top, which is jarring.
<a href="#" onclick="openMenu()">Menu</a>The Real Fix
If the control performs an action, use a real button. You get focus, keyboard support, and the correct role for free.
<button type="button" onclick="openMenu()">Menu</button>When It Should Be a Link
If the control truly navigates, keep the anchor but give it a real href pointing to the destination.
<a href="/menu">Menu</a>Why People Do This
Developers often pick an anchor for its underline styling. But you can style a button instead, without sacrificing accessibility.
Cursor Lies Too
An href-less anchor even loses its pointer cursor by default, hinting to sighted users that nothing is really clickable here.
The Takeaway
Do not fake interactivity. Choose a real button for actions or an anchor with an href for navigation, and skip the workarounds.
Quick Check
Why is an anchor with no href but a click handler a problem?
Recap
An href-less anchor is a fake link: unfocusable and keyboard-dead. Use a button for actions, a real href for navigation. ✅
الأسئلة الشائعة
هل درس «النمط المضاد للمرساة التي بلا href» مجاني؟
نعم — نص درس «النمط المضاد للمرساة التي بلا href» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Web Accessibility Academy، انتقل إلى CoddyKit PRO. تتضمن دورة Web Accessibility Academy 4 دروس في المجموع.
ماذا ستتعلم في «النمط المضاد للمرساة التي بلا href»؟
تعرّف إلى سبب تعطيل الرابط الوهمي لمستخدمي لوحة المفاتيح وقارئات الشاشة. تتمرن على Web Accessibility Academy مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.
هل أحتاج إلى خبرة سابقة لأبدأ Web Accessibility Academy؟
لا تُشترط خبرة سابقة. Web Accessibility Academy على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.
كم من الوقت يستغرق درس «النمط المضاد للمرساة التي بلا href»؟
معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.
هل يمكنني كتابة وتشغيل أكواد في درس Web Accessibility Academy هذا؟
نعم. كل درس في Web Accessibility Academy يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.
جميع الدروس في هذه الدورة
- الروابط تنقلك إلى أماكن والأزرار تنفّذ أفعالاً
- نص رابط مفهوم خارج السياق
- أزرار توضّح ما تفعله
- النمط المضاد للمرساة التي بلا href