Home >
Web Front-end >
JS Tutorial >
Example of simple form standardization - semantic structure_form special effects
Example of simple form standardization - semantic structure_form special effects
WBOY
Release: 2016-05-16 19:19:00
Original
1103 people have browsed it
1. Use fieldset and legend tags
In forms, we often group the information in the form. For example, in a registration form, we may group the registration information into basic information (generally required), details Information (generally optional), so how can we achieve it better? We can consider adding the following two tags to the form:
Fieldset is bordered by default , and legend is generally displayed in the upper left corner by default. But in some cases, you may not want to let the default styles or default layouts of fieldsets and legends affect the aesthetics of the design.
Solution: Set the fieldset's border to 0 and the legend's display to none in CSS. 2. Use label label We give a label label to the text label in the form, and use the for attribute to associate it with the form component. The effect is that when you click the text label, the cursor Displayed in the corresponding form component.
In addition to the above methods, we can also use label to nest the entire form component and text label, such as: < label for="fname">First name: According to the specification, the text will automatically Associated with adjacent form components, but unfortunately - the current mainstream browser IE6 does not support this feature. 3. Use the accesskey and tabindex attributes The website should take into account more situations. For example, when there is no cursor device (such as a mouse), the form can also be completed using keyboard operations. Filling in, clicking at this time has no meaning for them. At this time, we choose label's accesskey (shortcut key, alt accesskey attribute value under IE, alt shift accesskey attribute value under FF) and tabindex attribute (Tab key, tabindex attribute value is sequence) to add to the form label, such as label, input etc.
4. optgroup 태그 사용 optgroup 태그의 역할은 선택 목록에서 옵션 세트를 정의하는 것입니다. optgroup 태그를 사용하여 select 요소의 옵션을 분류하고 label 속성을 사용하도록 선택할 수 있습니다. 속성 값은 드롭다운 목록(select)에서 선택할 수 없는 들여쓰기 제목으로 표시됩니다. 참고: optgroup은 중첩을 지원하지 않습니다.
여기 IE6.0의 하나입니다. 작은 버그(FireFox에는 없음): IE에서 키보드 화살표 키를 사용하여 선택할 때 선택한 항목이 한 optgroup의 옵션에서 다른 optgroup의 옵션으로 변경되면 onchange가 작동하지 않습니다. 트리거되었습니다. 해결책은 문제 해결에 도움이 되도록 onkeydown 또는 onkeyup 이벤트를 추가하는 것입니다.
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn