freeCodeCamp/curriculum/challenges/russian/01-responsive-web-design/applied-accessibility/improve-form-field-accessib...

4.7 KiB
Raw Blame History

id title challengeType videoUrl localeTitle
587d778a367417b2b2512aa6 Improve Form Field Accessibility with the label Element 0 Улучшить доступность поля формы с помощью элемента Element

Description

Улучшение доступности с семантической разметкой HTML применяется к использованию как соответствующих имен тегов, так и атрибутов. Следующие несколько проблем охватывают некоторые важные сценарии с использованием атрибутов в формах. label метки обертывает текст для определенного элемента управления формой, как правило, имя или ярлык для выбора. Это связывает смысл с элементом и делает форму более читаемой. for атрибута на label тега явно связывает эту label с контролем формы и используется для чтения с экрана. Вы узнали о переключателях и их ярлыках в уроке в разделе «Основные HTML». В этом уроке мы завернули элемент ввода переключателя внутри элемента label вместе с текстом ярлыка, чтобы сделать текст кликабельным. Другой способ добиться этого - использовать атрибут for как объяснено в этом уроке. Значение атрибута for должно быть таким же, как значение атрибута id элемента управления формой. Вот пример:
<Форма>
<label for = "name"> Имя: </ label>
<input type = "text" id = "name" name = "name">
</ Форма>

Instructions

Camper Cat ожидает большой интерес к его задумчивым сообщениям в блоге и хочет включить форму для регистрации электронной почты. Добавить for атрибута электронной label , которая соответствует id на его input поле.

Tests

tests:
  - text: ''
    testString: 'assert($("label").attr("for"), "Your code should have a <code>for</code> attribute on the <code>label</code> tag that is not empty.");'
  - text: ''
    testString: 'assert($("label").attr("for") == "email", "Your <code>for</code> attribute value should match the <code>id</code> value on the email <code>input</code>.");'

Challenge Seed

<body>
  <header>
    <h1>Deep Thoughts with Master Camper Cat</h1>
  </header>
  <section>
    <form>
      <p>Sign up to receive Camper Cat's blog posts by email here!</p>


      <label>Email:</label>
      <input type="text" id="email" name="email">


      <input type="submit" name="submit" value="Submit">
    </form>
  </section>
  <article>
    <h2>The Garfield Files: Lasagna as Training Fuel?</h2>
    <p>The internet is littered with varying opinions on nutritional paradigms, from catnip paleo to hairball cleanses. But let's turn our attention to an often overlooked fitness fuel, and examine the protein-carb-NOM trifecta that is lasagna...</p>
  </article>
  <img src="samuraiSwords.jpeg" alt="">
  <article>
    <h2>Defeating your Foe: the Red Dot is Ours!</h2>
    <p>Felines the world over have been waging war on the most persistent of foes. This red nemesis combines both cunning stealth and lightening speed. But chin up, fellow fighters, our time for victory may soon be near...</p>
  </article>
  <img src="samuraiSwords.jpeg" alt="">
  <article>
    <h2>Is Chuck Norris a Cat Person?</h2>
    <p>Chuck Norris is widely regarded as the premier martial artist on the planet, and it's a complete coincidence anyone who disagrees with this fact mysteriously disappears soon after. But the real question is, is he a cat person?...</p>
  </article>
  <footer>&copy; 2018 Camper Cat</footer>
</body>

Solution

// solution required