315 |
316 |
317 | ### 네임스페이스를 생략해라
318 |
319 | HTML5 문서에서 SVG와 MathML은 바로 쓸 수 있다.
320 |
321 | Bad:
322 |
323 |
324 | ...
325 |
326 |
327 | Good:
328 |
329 |
330 | ...
331 |
332 |
333 |
334 | ### XML 속성을 쓰지 마라
335 |
336 | 우린 HTML 문서를 쓰고있다.
337 |
338 | Bad:
339 |
340 | ...
341 |
342 | Good:
343 |
344 | ...
345 |
346 |
347 | ### `data-*`, 마이크로데이터, RDFa Lite 속성을 일반 속성과 섞어쓰지 마라
348 |
349 | 태그 문자열이 아주 복잡할 수 있다.
350 | 이 간단한 규칙은 태그 문자열을 더 읽기 쉽게한다.
351 |
352 | Bad:
353 |
354 |
355 |
356 | Good:
357 |
358 |
359 |
360 |
361 | ### 기본 암시적 ARIA 시맨틱을 선호하라
362 |
363 | 일부 요소에서는 HTML 문서에서 ARIA `role`을 가지므로 지정하지 마라.
364 |
365 | Bad:
366 |
367 |
368 | ...
369 |
370 |
371 |
372 |
373 | Good:
374 |
375 |
376 | ...
377 |
378 |
379 |
380 |
381 |
382 | 루트 요소
383 | ----------------
384 |
385 | ### `lang` 속성을 추가해라
386 |
387 | `lang` 속성이 HTML 문서를 번역하는 데 도움을 줄거다.
388 |
389 | Bad:
390 |
391 |
392 |
393 | Good:
394 |
395 |
396 |
397 |
398 | ### `lang` 속성을 가능하면 짧게 유지해라
399 |
400 | 일본어는 Japan만 사용해라. 국가 코드는 필요없다.
401 |
402 | Bad:
403 |
404 |
405 |
406 | Good:
407 |
408 |
409 |
410 |
411 | ### `data-*`을 가능한 한 없애라
412 |
413 | 적절한 속성은 브라우저에서 처리할 수 있다.
414 |
415 | Bad:
416 |
417 | chemises
418 | ...
419 | Do not wash!
420 |
421 | Good:
422 |
423 | chemises
424 | ...
425 | Do not wash!
426 |
427 |
428 | 문서 메타데이터
429 | -----------------
430 |
431 | ### `title` 요소를 넣어라
432 |
433 | `title` 요소 값은 브라우저뿐만 아니라 다양한 어플리케이션에서 사용한다.
434 |
435 | Bad:
436 |
437 |
438 |
439 |
440 |
441 | Good:
442 |
443 |
444 |
445 | HTML Best Practices
446 |
447 |
448 |
449 | ### `base` 요소를 쓰지 마라
450 |
451 | 절대 경로나 URL은 개발자와 유저 모두에게 안전하다
452 |
453 | Bad:
454 |
455 |
456 | ...
457 |
458 |
459 | ...
460 |
461 |
462 | Good:
463 |
464 |
465 | ...
466 |
467 | ...
468 |
469 |
470 |
471 | ### 마이너한 링크 리소스에 MIME 타입을 정의해라
472 |
473 | 어플리케이션에서 리소스를 어떻게 처리하는 가에 대한 힌트다.
474 |
475 | Bad:
476 |
477 |
478 |
479 |
480 |
481 | Good:
482 |
483 |
484 |
485 |
486 |
487 |
488 | ### `favicon.ico` 링크하지 마라
489 |
490 | 대부분의 브라우저에서 `/favicon.ico`를 자동으로 비동기방식으로 가져온다.
491 |
492 | Bad:
493 |
494 |
495 |
496 | Good:
497 |
498 |
499 |
500 |
501 | ### 대체 스타일시트에 `title` 속성을 넣어라
502 |
503 | 사람이 읽을 수 있는 레이블은 스타일시트를 선택하는 데 도움을 줄거다.
504 |
505 | Bad:
506 |
507 |
508 |
509 |
510 | Good:
511 |
512 |
513 |
514 |
515 |
516 | ### URL을 위해서 `link` 요소를 써라
517 |
518 | `href` 속성 값이 URL로 해석된다.
519 |
520 | Bad:
521 |
522 |
526 |
527 | Good:
528 |
529 |
533 |
534 |
535 | ### 문서의 문자 인코딩을 정의해라
536 |
537 | 아직 UTF-8이 모든 브라우저에서 기본이 아니다.
538 |
539 | Bad:
540 |
541 |
542 | HTML Best Practices
543 |
544 |
545 | Good:
546 |
547 |
548 |
549 | HTML Best Practices
550 |
551 |
552 |
553 | ### 레거시 인코딩 포맷을 쓰지 마라
554 |
555 | HTTP 헤더는 서버에서 정의해야하며, 아주 쉽다.
556 |
557 | Bad:
558 |
559 |
560 |
561 | Good:
562 |
563 |
564 |
565 |
566 | ### 문자 인코딩을 처음으로 선언해라
567 |
568 | 스펙상 문자 인코딩이 문서의 첫 1024 바이트 내에 지정되어있어야 한다.
569 |
570 | Bad:
571 |
572 |
573 |
574 |
575 | ...
576 |
577 |
578 | Good:
579 |
580 |
581 |
582 |
583 | ...
584 |
585 |
586 |
587 | ### UTF-8을 써라
588 |
589 | UTF-8과 함께라면, 이모티콘을 자유롭게 쓸 수 있다.
590 |
591 | Bad:
592 |
593 |
594 |
595 | Good:
596 |
597 |
598 |
599 |
600 | ### CSS를 위한 `type` 속성을 생략해라
601 |
602 | HTML5에서, `style` 요소의 기본 `type` 속성 값은 `text/css`다.
603 |
604 | Bad:
605 |
606 |
609 |
610 | Good:
611 |
612 |
615 |
616 |
617 | ### `style` 요소의 내용을 주석처리하지 마라
618 |
619 | 이는 오랜 브라우저를 위한 것이다.
620 |
621 | Bad:
622 |
623 |
628 |
629 | Good:
630 |
631 |
634 |
635 |
636 | ### CSS와 JavaScript 태그를 섞지 말아라
637 |
638 | 때론 `script` 요소가 DOM 구성을 막기도 한다.
639 |
640 | Bad:
641 |
642 |
643 |
644 |
645 |
646 | Good:
647 |
648 |
649 |
650 |
651 |
652 | Also good:
653 |
654 |
655 |
656 |
657 |
658 |
659 | 섹션
660 | --------
661 |
662 | ### `body` 요소를 넣어라
663 |
664 | 때로 `body`를 브라우저에서 넣을 때 원치 않은 위치에 있기도 한다.
665 |
666 | Bad:
667 |
668 |
669 |
670 | ...
671 |
672 | ...
673 |
674 |
675 | Good:
676 |
677 |
678 |
679 | ...
680 |
681 |
682 | ...
683 |
684 |
685 |
686 |
687 | ### `hgroup` 요소는 잊어라
688 |
689 | W3C 스펙에서 삭제되었다.
690 |
691 | Bad:
692 |
693 |
694 | HTML Best Practices
695 | For writing maintainable and scalable HTML documents.
696 |
697 |
698 | Good:
699 |
700 | HTML Best Practices
701 | For writing maintainable and scalable HTML documents.
702 |
703 |
704 | ### `address` 요소는 콘택트 정보를 제공하는 데만 써라
705 |
706 | `address` 요소는 이메일 주소, 소셜 네트워크 계정, 주소, 전화번호 등 직접 연락할 수 있는 항목이다.
707 |
708 | Bad:
709 |
710 | No rights reserved.
711 |
712 | Good:
713 |
714 | Contact: Kyo Nagashima
715 |
716 |
717 | 그룹 콘텐츠
718 | ----------------
719 |
720 | ### `pre` 요소에서 새 줄로 시작하지 말아라
721 |
722 | 첫번째 줄바꿈은 브라우저에서 무시하지만, 두번째부터는 렌더링된다.
723 |
724 | Bad:
725 |
726 |
727 | <!DOCTYPE html>
728 |
729 |
730 | Good:
731 |
732 | <!DOCTYPE html>
733 |
734 |
735 |
736 | ### `blockquote` 요소에 적절한 요소를 써라
737 |
738 | `blockquote` 요소의 콘텐츠은 인용한 내용이지, 문장 덩어리가 아니다.
739 |
740 | Bad:
741 |
742 | For writing maintainable and scalable HTML documents.
743 |
744 | Good:
745 |
746 |
747 | For writing maintainable and scalable HTML documents.
748 |
749 |
750 |
751 | ### `blockquote` 요소 안에 직접 포함하지 마라
752 |
753 | `blockquote` 요소의 콘텐츠는 인용구다.
754 |
755 | Bad:
756 |
757 |
758 | For writing maintainable and scalable HTML documents.
759 |
760 | — HTML Best Practices
761 |
762 |
763 | Good:
764 |
765 |
766 | For writing maintainable and scalable HTML documents.
767 |
768 |
769 | — HTML Best Practices
770 |
771 | Also good (recommended by WHATWG):
772 |
773 |
774 |
775 | For writing maintainable and scalable HTML documents.
776 |
777 |
778 | — HTML Best Practices
779 |
780 |
781 | Also good too (recommended by W3C):
782 |
783 |
784 | For writing maintainable and scalable HTML documents.
785 |
786 |
787 |
788 |
789 |
790 | ### 한 줄에 한 리스트 아이템을 써라
791 |
792 | 기이ㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣㅣ인
793 | 라인은 너무ㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜㅜ 읽기 힘들다.
794 |
795 | Bad:
796 |
797 |
798 | General The root Element Sections ...
799 |
800 |
801 | Good:
802 |
803 |
804 | General
805 | The root Element
806 | Sections
807 | ...
808 |
809 |
810 |
811 | ### `ol` 요소에 `type` 속성을 써라
812 |
813 | 때로는 주변 콘텐츠에 의해 마커가 참조된다. 만약 `type` 속성으로 마커를 변경한다면,
814 | 참조하는 것이 안전하다.
815 |
816 | Bad:
817 |
818 |
819 |
824 |
825 |
826 |
827 | General
828 | The root Element
829 | Sections
830 | ...
831 |
832 |
833 |
834 | Good:
835 |
836 |
837 |
838 | General
839 | The root Element
840 | Sections
841 | ...
842 |
843 |
844 |
845 |
846 | ### 다이얼로그를 위해 `dl`을 쓰지 마라
847 |
848 | `dl` 요소는 HTML5의 연결 목록으로 제한한다.
849 |
850 | Bad:
851 |
852 |
853 | Costello
854 | Look, you gotta first baseman?
855 | Abbott
856 | Certainly.
857 | Costello
858 | Who’s playing first?
859 | Abbott
860 | That’s right.
861 | Costello becomes exasperated.
862 | Costello
863 | When you pay off the first baseman every month, who gets the money?
864 | Abbott
865 | Every dollar of it.
866 |
867 |
868 | Good:
869 |
870 | Costello: Look, you gotta first baseman?
871 | Abbott: Certainly.
872 | Costello: Who’s playing first?
873 | Abbott: That’s right.
874 | Costello becomes exasperated.
875 | Costello: When you pay off the first baseman every month, who gets the money?
876 | Abbott: Every dollar of it.
877 |
878 |
879 | ### `figcaption` 요소를 `figure` 요소의 첫째 or 마지막 자식요소로 써라
880 |
881 | 스펙 (WHATWG 버전)에서 `figcaption` 요소를 `figure` 요소 중간에 두는 걸 허용하지 않는다.
882 |
883 | Bad:
884 |
885 |
886 |
887 | “HTML Best Practices” Cover Art
888 |
889 |
890 |
891 | Good:
892 |
893 |
894 |
895 |
896 | “HTML Best Practices” Cover Art
897 |
898 |
899 |
900 | ### `main` 요소를 써라
901 |
902 | `main` 요소는 콘텐츠를 감쌀 때 쓸 수 있다.
903 |
904 | Bad:
905 |
906 |
907 | ...
908 |
909 |
910 | Good:
911 |
912 |
913 | ...
914 |
915 |
916 |
917 | ### `div` 요소를 가능한 한 많이 없애라
918 |
919 | `div` 요소는 최후의 수단이다.
920 |
921 | Bad:
922 |
923 |
924 | ...
925 |
926 |
927 | Good:
928 |
929 |
932 |
933 |
934 | Text-level 시맨틱
935 | --------------------
936 |
937 | ### 그룹 가능한 동일 링크를 분리하지 마라
938 |
939 | `a` 요소는 대부분의 요소를 감쌀 수 있다. (`a` 요소 자신이나 컨트롤같은 인터렉티브 요소는 제외한다)
940 |
941 | Bad:
942 |
943 |
944 |
945 | A community maintaining and evolving HTML since 2004.
946 |
947 | Good:
948 |
949 |
950 | WHATWG
951 |
952 | A community maintaining and evolving HTML since 2004.
953 |
954 |
955 |
956 | ### 리소스를 다운하고자 할 때 `download` 속성을 사용하라
957 |
958 | 브라우저에서 연결된 리소스를 스토리지에서 다운받으려 할거다.
959 |
960 | Bad:
961 |
962 | offline version
963 |
964 | Good:
965 |
966 | offline version
967 |
968 |
969 | ### 필요하다면 `rel`, `hreflang`, `type` 속성을 사용해라
970 |
971 | 이러한 힌트는 어플리케이션에서 연결된 리소스를 제어하는 데 사용한다.
972 |
973 | Bad:
974 |
975 | Japanese PDF version
976 |
977 | Good:
978 |
979 | Japanese PDF version
980 |
981 |
982 | ### 링크 텍스트를 명확히 하라
983 |
984 | 링크 텍스트는 연결된 리소스의 레이블이어야한다.
985 |
986 | Bad:
987 |
988 | Click here to view PDF version.
989 |
990 | Good:
991 |
992 | PDF version is also available.
993 |
994 |
995 | ### 경고나 주의를 위해 `em`을 사용하지 말아라
996 |
997 | 이것들은 심각하다. 따라서 `storng` 요소가 더 적절하다.
998 |
999 | Bad:
1000 |
1001 | Caution!
1002 |
1003 | Good:
1004 |
1005 | Caution!
1006 |
1007 |
1008 | ### `s`, `i`, `b`, `u` 요소를 가능한 한 없애라
1009 |
1010 | 이 요소의 시맨틱은 사람과 아주 다르다.
1011 |
1012 | Bad:
1013 |
1014 |
1015 |
1016 | Good:
1017 |
1018 |
1019 |
1020 |
1021 | ### `q` 요소에 따옴표를 넣지 말아라
1022 |
1023 | 브라우저에서 제공한다.
1024 |
1025 | Bad:
1026 |
1027 | “For writing maintainable and scalable HTML documents”
1028 |
1029 | Good:
1030 |
1031 | For writing maintainable and scalable HTML documents
1032 |
1033 | Also good:
1034 |
1035 | “For writing maintainable and scalable HTML documents”
1036 |
1037 |
1038 | ### `abbr` 요소에 `title` 속성을 써라
1039 |
1040 | 무엇의 함축어인 지 달리 설명할 길이 없다.
1041 |
1042 | Bad:
1043 |
1044 | HBP
1045 |
1046 | Good:
1047 |
1048 | HBP
1049 |
1050 |
1051 | ### `ruby` 요소를 자세히 마크업해라
1052 |
1053 | `ruby` 요소를 모든 모던 브라우저에서 완전하게 지원하는 게 아니다.
1054 |
1055 | Bad:
1056 |
1057 | HTMLえいちてぃーえむえる
1058 |
1059 | Good:
1060 |
1061 | HTML ( えいちてぃーえむえる )
1062 |
1063 |
1064 | ### 기계가 읽을 수 없는 `time` 요소에 `datetime` 속성을 추가해라
1065 |
1066 | `datetime` 속성이 없을 때, `time` 요소의 포맷은 제한된다.
1067 |
1068 | Bad:
1069 |
1070 | Dec 19, 2014
1071 |
1072 | Good:
1073 |
1074 | Dec 19, 2014
1075 |
1076 |
1077 | ### `class` 속성 접두어로 `language-`를 넣어 code 언어를 정의하라
1078 |
1079 | 일반적이진 않지만, spec에 언급되어있다.
1080 |
1081 | Bad:
1082 |
1083 | <!DOCTYPE html>
1084 |
1085 | Good:
1086 |
1087 | <!DOCTYPE html>
1088 |
1089 |
1090 | ### `kbd` 요소를 가능한 한 단순하게 둬라
1091 |
1092 | `kbd` 요소를 감싸는 건 사람과 다르다.
1093 |
1094 | Bad:
1095 |
1096 | Ctrl +F5
1097 |
1098 | Good:
1099 |
1100 | Ctrl+F5
1101 |
1102 |
1103 | ### `span` 요소를 가능한 한 많이 제거해라.
1104 |
1105 | `span` 요소는 최후의 수단이다.
1106 |
1107 | Bad:
1108 |
1109 | HTML Best Practices
1110 |
1111 | Good:
1112 |
1113 | HTML Best Practices
1114 |
1115 |
1116 | ### `br` 요소 뒤에 줄바꿈해라
1117 |
1118 | `br` 요소를 사용하면 줄바꿈 하는 게 좋다.
1119 |
1120 | Bad:
1121 |
1122 | HTML Best Practices
1123 |
1124 | Good:
1125 |
1126 | HTML
1127 | Best
1128 | Practices
1129 |
1130 |
1131 | ### 프레젠테이션 목적으로만 `br` 요소를 쓰지 마라
1132 |
1133 | `br` 요소는 줄바꿈을 위해서가 아니라, 콘텐츠의 라인 구분을 위해 사용한다.
1134 |
1135 | Bad:
1136 |
1137 | Rule name:
1138 | Rule description:
1139 |
1140 |
1141 | Good:
1142 |
1143 | Rule name:
1144 | Rule description:
1145 |
1146 |
1147 |
1148 | 에디트
1149 | -----
1150 |
1151 | ### `ins`와 `del` 요소로 다른 요소를 뛰어넘지 마라
1152 |
1153 | 요소는 다른 요소를 넘을 수 없다.
1154 |
1155 | Bad:
1156 |
1157 | For writing maintainable and scalable HTML documents. And for mental stability.
1158 |
1159 | Don’t trust!
1160 |
1161 | Good:
1162 |
1163 | For writing maintainable and scalable HTML documents. And for mental stability.
1164 |
1165 | Don’t trust!
1166 |
1167 |
1168 | Embedded 콘텐츠
1169 | ----------------
1170 |
1171 | ### `picture` 요소의 폴백으로 `img` 요소를 제공해라
1172 |
1173 | `picture` 요소 지원율이 아직 그렇게 높지 않다.
1174 |
1175 | Bad:
1176 |
1177 |
1178 |
1179 |
1180 |
1181 |
1182 |
1183 |
1184 | Good:
1185 |
1186 |
1187 |
1188 |
1189 |
1190 |
1191 |
1192 |
1193 |
1194 | ### 만약 필요하다면 `img` 요소에 `alt` 속성을 추가해라
1195 |
1196 | `alt` 속성은 이미지를 처리할 수 없거나 불러오지 못했을 때 도움을 준다.
1197 |
1198 | Bad:
1199 |
1200 |
1201 |
1202 | Good:
1203 |
1204 |
1205 |
1206 |
1207 | ### 가능한 경우 `alt` 속성을 비워둬라
1208 |
1209 | 본문을 보충하는 이미지라면, 근처에 동일한 콘텐츠가 있다.
1210 |
1211 | Bad:
1212 |
1213 | Help
1214 |
1215 | Good:
1216 |
1217 | Help
1218 |
1219 |
1220 | ### 가능한 경우 `alt` 속성을 생략해라
1221 |
1222 | 때때로 어떤 텍스트가 alt 속성에 적합한 지 모를 수 있다.
1223 | (역주) spec에서 `alt` 속성은 특수한 케이스가 아니라면 필수 속성이므로 빈값으로 넣어주세요.
1224 |
1225 | Bad:
1226 |
1227 |
1228 |
1229 | Good:
1230 |
1231 |
1232 | (If you cannot see the image, you can use an audio test instead.)
1233 |
1234 |
1235 | ### `iframe` 요소를 비워둬라
1236 |
1237 | 콘텐츠에 몇가지 제한사항이 있다. 비워두면 항상 안전하다.
1238 |
1239 | Bad:
1240 |
1241 |
1244 |
1245 | Good:
1246 |
1247 |
1248 |
1249 |
1250 | ### `map` 요소 콘텐츠도 마크업해라
1251 |
1252 | 스크린 리더의 콘텐츠 프리셋으로 쓰인다.
1253 |
1254 | Bad:
1255 |
1256 |
1257 | General
1258 | |
1259 | The root element
1260 | |
1261 | Sections
1262 |
1263 |
1264 |
1265 | Good:
1266 |
1267 |
1268 |
1269 | General
1270 | |
1271 | The root element
1272 | |
1273 | Sections
1274 |
1275 |
1276 |
1277 |
1278 |
1279 | ### `audio`나 `video` 요소를 위한 폴백 콘텐츠를 제공해라.
1280 |
1281 | HTML5에 새로 추가된 요소들을 위해 폴백 콘텐츠가 필요하다.
1282 |
1283 | Bad:
1284 |
1285 |
1286 |
1287 |
1288 | ...
1289 |
1290 |
1291 | Good:
1292 |
1293 |
1294 |
1295 |
1296 | ...
1297 |
1298 |
1299 |
1300 |
1301 | 테이블 데이터
1302 | ------------
1303 |
1304 | ### 한 줄에 한 셀만 써라
1305 |
1306 | 긴 라인은 스캔하기 힘들다.
1307 |
1308 | Bad:
1309 |
1310 |
1311 | General The root Element Sections
1312 |
1313 |
1314 | Good:
1315 |
1316 |
1317 | General
1318 | The root Element
1319 | Sections
1320 |
1321 |
1322 |
1323 | ### `th` 요소를 헤더 셀로 써라
1324 |
1325 | 안 쓸 이유가 없다.
1326 |
1327 | Bad:
1328 |
1329 |
1330 |
1331 |
1332 | Element
1333 | Empty
1334 | Tag omission
1335 |
1336 |
1337 |
1338 |
1339 | pre
1340 | No
1341 | Neither tag is omissible
1342 |
1343 |
1344 | img
1345 | Yes
1346 | No end tag
1347 |
1348 |
1349 |
1350 |
1351 | Good:
1352 |
1353 |
1354 |
1355 |
1356 | Element
1357 | Empty
1358 | Tag omission
1359 |
1360 |
1361 |
1362 |
1363 | pre
1364 | No
1365 | Neither tag is omissible
1366 |
1367 |
1368 | img
1369 | Yes
1370 | No end tag
1371 |
1372 |
1373 |
1374 |
1375 |
1376 | 폼
1377 | -----
1378 |
1379 | ### 폼 컨트롤을 `label` 요소로 감싸라
1380 |
1381 | `label` 요소가 폼 요소에 포커스를 주는 데 도움을 준다
1382 |
1383 | Bad:
1384 |
1385 | Query:
1386 |
1387 | Good:
1388 |
1389 | Query:
1390 |
1391 |
1392 | ### 가능한 경우 `for` 속성을 생략해라
1393 |
1394 | `label` 요소는 몇가지 폼 요소를 감쌀 수 있다.
1395 |
1396 | Bad:
1397 |
1398 | Query:
1399 |
1400 | Good:
1401 |
1402 | Query:
1403 |
1404 |
1405 | ### `input` 요소에 적절한 `type` 속성을 사용해라
1406 |
1407 | 적절한 `type`을 사용하면, 브라우저에서 `input` 요소에 작은 기능을 제공한다.
1408 |
1409 | Bad:
1410 |
1411 | Search keyword:
1412 |
1413 | Good:
1414 |
1415 | Search keyword:
1416 |
1417 |
1418 | ### `input type="submit"`에 `value` 속성을 넣어라
1419 |
1420 | submit 버튼의 기본 레이블은 브라우저 및 언어 사이 표준이 없다.
1421 |
1422 | Bad:
1423 |
1424 |
1425 |
1426 | Good:
1427 |
1428 |
1429 |
1430 |
1431 | ### `input` 요소에 `pattern` 속성이 있는 경우 `title` 속성을 추가해라
1432 |
1433 | 입력한 텍스트가 `pattern` 속성과 매치하지 않는 경우,
1434 | `title` 속성의 값이 힌트가 될거다.
1435 |
1436 | Bad:
1437 |
1438 |
1439 |
1440 | Good:
1441 |
1442 |
1443 |
1444 |
1445 | ### 레이블하기 위해 `placeholder` 속성을 쓰지 마라
1446 |
1447 | `label` 요소가 레이블을 위한 요소고, `placeholder` 속성은 짧은 힌트를 위한 속성이다.
1448 |
1449 | Bad:
1450 |
1451 |
1452 |
1453 | Good:
1454 |
1455 | Email:
1456 |
1457 |
1458 | ### 한 줄에 한 `option` 요소만 사용해라
1459 |
1460 | 긴 라인은 읽기 힘들다.
1461 |
1462 | Bad:
1463 |
1464 |
1465 |
1466 |
1467 |
1468 | Good:
1469 |
1470 |
1471 |
1472 |
1473 |
1474 |
1475 |
1476 |
1477 | ### `progress` 요소에 `max` 속성을 추가해라
1478 |
1479 | `max` 속성을 통해, `value` 속성을 쉬운 포맷으로 쓸 수 있다.
1480 |
1481 | Bad:
1482 |
1483 | 50%
1484 |
1485 | Good:
1486 |
1487 | 50%
1488 |
1489 |
1490 | ### `meter` 요소에 `min`, `max` 속성을 추가해라
1491 |
1492 | `min`, `max` 속성을 통해, `value` 속성을 쉬운 포맷으로 쓸 수 있다.
1493 |
1494 | Bad:
1495 |
1496 | 512GB used (1024GB total)
1497 |
1498 | Good:
1499 |
1500 | 512GB used (1024GB total)
1501 |
1502 |
1503 | ### `legend` 요소를 `fieldset` 요소의 첫번째 자식으로 둬라.
1504 |
1505 | 스펙 필수 사항이다.
1506 |
1507 | Bad:
1508 |
1509 |
1510 | Is this section is useful?:
1511 | ...
1512 | About "General"
1513 |
1514 |
1515 | Good:
1516 |
1517 |
1518 | About "General"
1519 | Is this section is useful?:
1520 | ...
1521 |
1522 |
1523 |
1524 | 스크립트
1525 | ---------
1526 |
1527 | ### 자바스크립트를 위한 `type` 속성을 생략해라
1528 |
1529 | HTML5에서, `script` 요소의 기본 `type` 속성값은 `text/javascript`다.
1530 |
1531 | Bad:
1532 |
1533 |
1536 |
1537 | Good:
1538 |
1539 |
1542 |
1543 |
1544 | ### `script` 요소의 내용을 주석처리하지 마라
1545 |
1546 | 이는 오랜 브라우저를 위한 것이다.
1547 |
1548 | Bad:
1549 |
1550 |
1555 |
1556 | Also bad:
1557 |
1558 |
1563 |
1564 | Good:
1565 |
1566 |
1569 |
1570 |
1571 | ### 스크립트가 삽입된 `script` 요소를 쓰지 마라
1572 |
1573 | `async` 속성은 성능면으로나 단순성면으로나 최고다.
1574 |
1575 | Bad:
1576 |
1577 |
1583 |
1584 | Good:
1585 |
1586 |
1587 |
1588 |
1589 | 기타
1590 | -----
1591 |
1592 | ### 일관된 들여쓰기
1593 |
1594 | 일관성은 가독성에 중요하다.
1595 |
1596 | Bad:
1597 |
1598 |
1599 |
1600 | ...
1601 |
1602 |
1603 | ...
1604 |
1605 |
1606 |
1607 | Good:
1608 |
1609 |
1610 |
1611 | ...
1612 |
1613 |
1614 | ...
1615 |
1616 |
1617 |
1618 |
1619 | ### 내부 링크에 절대 경로를 사용해라
1620 |
1621 | 절대 경로는 인터넷 연결 없이도 localhost에서도 동작한다.
1622 |
1623 | Bad:
1624 |
1625 |
1626 | ...
1627 | You can find more at contact page .
1628 |
1629 | Good:
1630 |
1631 |
1632 | ...
1633 | You can find more at contact page .
1634 |
1635 |
1636 | Contributors
1637 | ------------
1638 |
1639 | - [@hail2u]
1640 | - [@momdo]
1641 | - [@techhtml]
1642 |
1643 |
1644 | License
1645 | -------
1646 |
1647 | [CC0]
1648 |
1649 |
1650 | [@hail2u]: https://github.com/hail2u
1651 | [@momdo]: https://github.com/momdo
1652 | [@techhtml]: https://github.com/techhtml
1653 | [CC0]: http://creativecommons.org/publicdomain/zero/1.0/
1654 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Translations: [English (en)](README.md) · [日本語 (ja)](README.ja.md) · [한국어 (ko)](README.ko.md)
2 |
3 | HTML Best Practices
4 | ===================
5 |
6 | For writing maintainable and scalable HTML documents
7 |
8 |
9 |
10 | * [General](#general)
11 | * [Start with DOCTYPE](#start-with-doctype)
12 | * [Don’t use legacy or obsolete DOCTYPE](#dont-use-legacy-or-obsolete-doctype)
13 | * [Don’t use XML Declaration](#dont-use-xml-declaration)
14 | * [Don’t use character references as much as possible](#dont-use-character-references-as-much-as-possible)
15 | * [Escape `&`, `<`, `>`, `"`, and `'` with named character references](#escape-----and--with-named-character-references)
16 | * [Use numeric character references for control or invisible characters](#use-numeric-character-references-for-control-or-invisible-characters)
17 | * [Put white spaces around comment contents](#put-white-spaces-around-comment-contents)
18 | * [Don’t omit closing tag](#dont-omit-closing-tag)
19 | * [Don’t mix empty element format](#dont-mix-empty-element-format)
20 | * [Don’t put white spaces around tags and attribute values](#dont-put-white-spaces-around-tags-and-attribute-values)
21 | * [Don’t mix character cases](#dont-mix-character-cases)
22 | * [Don’t mix quotation marks](#dont-mix-quotation-marks)
23 | * [Don’t separate attributes with two or more white spaces](#dont-separate-attributes-with-two-or-more-white-spaces)
24 | * [Omit boolean attribute value](#omit-boolean-attribute-value)
25 | * [Omit namespaces](#omit-namespaces)
26 | * [Don’t use XML attributes](#dont-use-xml-attributes)
27 | * [Don’t mix `data-*`, Microdata, and RDFa Lite attributes with common attributes](#dont-mix-data--microdata-and-rdfa-lite-attributes-with-common-attributes)
28 | * [Prefer default implicit ARIA semantics](#prefer-default-implicit-aria-semantics)
29 | * [The root element](#the-root-element)
30 | * [Add `lang` attribute](#add-lang-attribute)
31 | * [Keep `lang` attribute value as short as possible](#keep-lang-attribute-value-as-short-as-possible)
32 | * [Avoid `data-*` as much as possible](#avoid-data--as-much-as-possible)
33 | * [Document metadata](#document-metadata)
34 | * [Add `title` element](#add-title-element)
35 | * [Don’t use `base` element](#dont-use-base-element)
36 | * [Specify MIME type of minor linked resources](#specify-mime-type-of-minor-linked-resources)
37 | * [Don’t link to `favicon.ico`](#dont-link-to-faviconico)
38 | * [Add `title` attribute to alternate stylesheets](#add-title-attribute-to-alternate-stylesheets)
39 | * [For URL, use `link` element](#for-url-use-link-element)
40 | * [Specify document character encoding](#specify-document-character-encoding)
41 | * [Don’t use legacy character encoding format](#dont-use-legacy-character-encoding-format)
42 | * [Specify character encoding at first](#specify-character-encoding-at-first)
43 | * [Use UTF-8](#use-utf-8)
44 | * [Omit `type` attribute for CSS](#omit-type-attribute-for-css)
45 | * [Don’t comment out contents of `style` element](#dont-comment-out-contents-of-style-element)
46 | * [Don’t mix tag for CSS and JavaScript](#dont-mix-tag-for-css-and-javascript)
47 | * [Sections](#sections)
48 | * [Add `body` element](#add-body-element)
49 | * [Forget about `hgroup` element](#forget-about-hgroup-element)
50 | * [Use `address` element only for contact information](#use-address-element-only-for-contact-information)
51 | * [Grouping content](#grouping-content)
52 | * [Don’t start with newline in `pre` element](#dont-start-with-newline-in-pre-element)
53 | * [Use appropriate element in `blockquote` element](#use-appropriate-element-in-blockquote-element)
54 | * [Don’t include attribution directly in `blockquote` element](#dont-include-attribution-directly-in-blockquote-element)
55 | * [Write one list item per line](#write-one-list-item-per-line)
56 | * [Use `type` attribute for `ol` element](#use-type-attribute-for-ol-element)
57 | * [Don’t use `dl` for dialogue](#dont-use-dl-for-dialogue)
58 | * [Place `figcaption` element as first or last child of `figure` element](#place-figcaption-element-as-first-or-last-child-of-figure-element)
59 | * [Use `main` element](#use-main-element)
60 | * [Avoid `div` element as much as possible](#avoid-div-element-as-much-as-possible)
61 | * [Text-level semantics](#text-level-semantics)
62 | * [Don’t split same link that can be grouped](#dont-split-same-link-that-can-be-grouped)
63 | * [Use `download` attribute for downloading a resource](#use-download-attribute-for-downloading-a-resource)
64 | * [Use `rel`, `hreflang`, and `type` attribute if needed](#use-rel-hreflang-and-type-attribute-if-needed)
65 | * [Clear link text](#clear-link-text)
66 | * [Don’t use `em` element for warning or caution](#dont-use-em-element-for-warning-or-caution)
67 | * [Avoid `s`, `i`, `b`, and `u` element as much as possible](#avoid-s-i-b-and-u-element-as-much-as-possible)
68 | * [Don’t put quotes to `q` element](#dont-put-quotes-to-q-element)
69 | * [Add `title` attribute to `abbr` element](#add-title-attribute-to-abbr-element)
70 | * [Markup `ruby` element verbosely](#markup-ruby-element-verbosely)
71 | * [Add `datetime` attribute to non-machine-readable `time` element](#add-datetime-attribute-to-non-machine-readable-time-element)
72 | * [Specify code language with `class` attribute prefixed with `language-`](#specify-code-language-with-class-attribute-prefixed-with-language-)
73 | * [Keep `kbd` element as simple as possible](#keep-kbd-element-as-simple-as-possible)
74 | * [Avoid `span` element as much as possible](#avoid-span-element-as-much-as-possible)
75 | * [Break after `br` element](#break-after-br-element)
76 | * [Don’t use `br` element only for presentational purpose](#dont-use-br-element-only-for-presentational-purpose)
77 | * [Edits](#edits)
78 | * [Don’t stride `ins` and `del` element over other elements](#dont-stride-ins-and-del-element-over-other-elements)
79 | * [Embedded content](#embedded-content)
80 | * [Provide fallback `img` element for `picture` element](#provide-fallback-img-element-for-picture-element)
81 | * [Add `alt` attrbute to `img` element if needed](#add-alt-attrbute-to-img-element-if-needed)
82 | * [Empty `alt` attribute if possible](#empty-alt-attribute-if-possible)
83 | * [Omit `alt` attribute if possible](#omit-alt-attribute-if-possible)
84 | * [Empty `iframe` element](#empty-iframe-element)
85 | * [Markup `map` element content](#markup-map-element-content)
86 | * [Provide fallback content for `audio` or `video` element](#provide-fallback-content-for-audio-or-video-element)
87 | * [Tabular data](#tabular-data)
88 | * [Write one cell per line](#write-one-cell-per-line)
89 | * [Use `th` element for header cell](#use-th-element-for-header-cell)
90 | * [Forms](#forms)
91 | * [Wrap form control with `label` element](#wrap-form-control-with-label-element)
92 | * [Omit `for` attribute if possible](#omit-for-attribute-if-possible)
93 | * [Use appropriate `type` attribute for `input` element](#use-appropriate-type-attribute-for-input-element)
94 | * [Add `value` attribute to `input type="submit"`](#add-value-attribute-to-input-typesubmit)
95 | * [Add `title` attribute to `input` element when there is `pattern` attribute](#add-title-attribute-to-input-element-when-there-is-pattern-attribute)
96 | * [Don’t use `placeholder` attribute for labeling](#dont-use-placeholder-attribute-for-labeling)
97 | * [Write one `option` element per line](#write-one-option-element-per-line)
98 | * [Add `max` attribute to `progress` element](#add-max-attribute-to-progress-element)
99 | * [Add `min` and `max` attribute to `meter` element](#add-min-and-max-attribute-to-meter-element)
100 | * [Place `legend` element as the first child of `fieldset` element](#place-legend-element-as-the-first-child-of-fieldset-element)
101 | * [Scripting](#scripting)
102 | * [Omit `type` attribute for JavaScript](#omit-type-attribute-for-javascript)
103 | * [Don’t comment out contents of `script` element](#dont-comment-out-contents-of-script-element)
104 | * [Don’t use script-injected `script` element](#dont-use-script-injected-script-element)
105 | * [Other](#other)
106 | * [Indent consistently](#indent-consistently)
107 | * [Use absolute path for internal links](#use-absolute-path-for-internal-links)
108 | * [Contributors](#contributors)
109 | * [License](#license)
110 |
111 |
112 |
113 |
114 | General
115 | -------
116 |
117 | ### Start with DOCTYPE
118 |
119 | DOCTYPE is required for activating standard mode.
120 |
121 | Bad:
122 |
123 |
124 | ...
125 |
126 |
127 | Good:
128 |
129 |
130 |
131 | ...
132 |
133 |
134 |
135 | ### Don’t use legacy or obsolete DOCTYPE
136 |
137 | DOCTYPE is not for DTD anymore, be simple.
138 |
139 | Bad:
140 |
141 |
143 |
144 | Good:
145 |
146 |
147 |
148 |
149 | ### Don’t use XML Declaration
150 |
151 | Are you sure you want to write XHTML?
152 |
153 | Bad:
154 |
155 |
156 |
157 |
158 | Good:
159 |
160 |
161 |
162 |
163 | ### Don’t use character references as much as possible
164 |
165 | If you write an HTML document with UTF-8, almost all charaters (including Emoji)
166 | can be write directly.
167 |
168 | Bad:
169 |
170 | Copyright © 2014 W3C®
171 |
172 | Good:
173 |
174 | Copyright © 2014 W3C®
175 |
176 |
177 | ### Escape `&`, `<`, `>`, `"`, and `'` with named character references
178 |
179 | These characters should escape always for a bug-free HTML document.
180 |
181 | Bad:
182 |
183 | The "&" character
184 |
185 | Good:
186 |
187 | The "&" character
188 |
189 |
190 | ### Use numeric character references for control or invisible characters
191 |
192 | These characters are easily mistaken for another character. And also spec does
193 | not guarantee to define a human readable name for these characters.
194 |
195 | Bad:
196 |
197 | This book can read in 1 hour.
198 |
199 | Good:
200 |
201 | This book can read in 1 hour.
202 |
203 |
204 | ### Put white spaces around comment contents
205 |
206 | Some character cannot be used immediately after comment open tag or before
207 | comment close tag.
208 |
209 | Bad:
210 |
211 |
212 |
213 | Good:
214 |
215 |
216 |
217 |
218 | ### Don’t omit closing tag
219 |
220 | I think you don’t understand a rule for omitting closing tag.
221 |
222 | Bad:
223 |
224 |
225 |
226 | ...
227 |
228 | Good:
229 |
230 |
231 |
232 | ...
233 |
234 |
235 |
236 |
237 | ### Don’t mix empty element format
238 |
239 | Consistency is a key for readability.
240 |
241 | Bad:
242 |
243 |
244 |
245 |
246 | Good:
247 |
248 |
249 |
250 |
251 |
252 | ### Don’t put white spaces around tags and attribute values
253 |
254 | There is no reason for doing this.
255 |
256 | Bad:
257 |
258 | HTML Best Practices
259 |
260 | Good:
261 |
262 | HTML Best Practices
263 |
264 |
265 | ### Don’t mix character cases
266 |
267 | It gives a consistency also.
268 |
269 | Bad:
270 |
271 | General
272 |
273 | Good:
274 |
275 | General
276 |
277 | Also Good:
278 |
279 | General
280 |
281 |
282 | ### Don’t mix quotation marks
283 |
284 | Same as above.
285 |
286 | Bad:
287 |
288 |
289 |
290 | Good:
291 |
292 |
293 |
294 |
295 | ### Don’t separate attributes with two or more white spaces
296 |
297 | Your weird formatting rule confuses someone.
298 |
299 | Bad:
300 |
301 |
302 |
303 | Good:
304 |
305 |
306 |
307 |
308 | ### Omit boolean attribute value
309 |
310 | It’s easy to write, isn’t it?
311 |
312 | Bad:
313 |
314 |
315 |
316 | Good:
317 |
318 |
319 |
320 |
321 | ### Omit namespaces
322 |
323 | SVG and MathML can be used directly in an HTML5 document.
324 |
325 | Bad:
326 |
327 |
328 | ...
329 |
330 |
331 | Good:
332 |
333 |
334 | ...
335 |
336 |
337 |
338 | ### Don’t use XML attributes
339 |
340 | We write an HTML document.
341 |
342 | Bad:
343 |
344 | ...
345 |
346 | Good:
347 |
348 | ...
349 |
350 |
351 | ### Don’t mix `data-*`, Microdata, and RDFa Lite attributes with common attributes
352 |
353 | A tag string can be very complicated. This simple rule helps reading such tag
354 | string.
355 |
356 | Bad:
357 |
358 |
359 |
360 | Good:
361 |
362 |
363 |
364 |
365 | ### Prefer default implicit ARIA semantics
366 |
367 | Some element has an ARIA `role` implicitly in an HTML document, don’t specify it.
368 |
369 | Bad:
370 |
371 |
372 | ...
373 |
374 |
375 |
376 |
377 | Good:
378 |
379 |
380 | ...
381 |
382 |
383 |
384 |
385 |
386 | The root element
387 | ----------------
388 |
389 | ### Add `lang` attribute
390 |
391 | `lang` attribute will help translating an HTML document.
392 |
393 | Bad:
394 |
395 |
396 |
397 | Good:
398 |
399 |
400 |
401 |
402 | ### Keep `lang` attribute value as short as possible
403 |
404 | Japanese is only used in Japan. So country code is not necessary.
405 |
406 | Bad:
407 |
408 |
409 |
410 | Good:
411 |
412 |
413 |
414 |
415 | ### Avoid `data-*` as much as possible
416 |
417 | An appropriate attribute can be handled properly by browsers.
418 |
419 | Bad:
420 |
421 | chemises
422 | ...
423 | Do not wash!
424 |
425 | Good:
426 |
427 | chemises
428 | ...
429 | Do not wash!
430 |
431 |
432 | Document metadata
433 | -----------------
434 |
435 | ### Add `title` element
436 |
437 | A value for `title` element is used by various application not only a browser.
438 |
439 | Bad:
440 |
441 |
442 |
443 |
444 |
445 | Good:
446 |
447 |
448 |
449 | HTML Best Practices
450 |
451 |
452 |
453 | ### Don’t use `base` element
454 |
455 | An absolute path or URL is safer for both developers and users.
456 |
457 | Bad:
458 |
459 |
460 | ...
461 |
462 |
463 | ...
464 |
465 |
466 | Good:
467 |
468 |
469 | ...
470 |
471 | ...
472 |
473 |
474 |
475 | ### Specify MIME type of minor linked resources
476 |
477 | This is a hint how application handles this resource.
478 |
479 | Bad:
480 |
481 |
482 |
483 |
484 |
485 | Good:
486 |
487 |
488 |
489 |
490 |
491 |
492 | ### Don’t link to `favicon.ico`
493 |
494 | Almost all browsers fetch `/favicon.ico` automatically and asynchronously.
495 |
496 | Bad:
497 |
498 |
499 |
500 | Good:
501 |
502 |
503 |
504 |
505 | ### Add `title` attribute to alternate stylesheets
506 |
507 | A human readable label helps people selecting proper stylesheet.
508 |
509 | Bad:
510 |
511 |
512 |
513 |
514 | Good:
515 |
516 |
517 |
518 |
519 |
520 | ### For URL, use `link` element
521 |
522 | A value of `href` attribute can be resolved as URL.
523 |
524 | Bad:
525 |
526 |
530 |
531 | Good:
532 |
533 |
537 |
538 |
539 | ### Specify document character encoding
540 |
541 | UTF-8 is not default in all browsers yet.
542 |
543 | Bad:
544 |
545 |
546 | HTML Best Practices
547 |
548 |
549 | Good:
550 |
551 |
552 |
553 | HTML Best Practices
554 |
555 |
556 |
557 | ### Don’t use legacy character encoding format
558 |
559 | HTTP headers should be specified by a server, be simple.
560 |
561 | Bad:
562 |
563 |
564 |
565 | Good:
566 |
567 |
568 |
569 |
570 | ### Specify character encoding at first
571 |
572 | Spec requires the character encoding is specified within the first 1024 bytes of
573 | the document.
574 |
575 | Bad:
576 |
577 |
578 |
579 |
580 | ...
581 |
582 |
583 | Good:
584 |
585 |
586 |
587 |
588 | ...
589 |
590 |
591 |
592 | ### Use UTF-8
593 |
594 | With UTF-8, you can free to use Emoji.
595 |
596 | Bad:
597 |
598 |
599 |
600 | Good:
601 |
602 |
603 |
604 |
605 | ### Omit `type` attribute for CSS
606 |
607 | In HTML5, default `type` attribute’s value of `style` element is `text/css`.
608 |
609 | Bad:
610 |
611 |
614 |
615 | Good:
616 |
617 |
620 |
621 |
622 | ### Don’t comment out contents of `style` element
623 |
624 | This ritual is for the old browser.
625 |
626 | Bad:
627 |
628 |
633 |
634 | Good:
635 |
636 |
639 |
640 |
641 | ### Don’t mix tag for CSS and JavaScript
642 |
643 | Sometimes `script` element blocks DOM construction.
644 |
645 | Bad:
646 |
647 |
648 |
649 |
650 |
651 | Good:
652 |
653 |
654 |
655 |
656 |
657 | Also good:
658 |
659 |
660 |
661 |
662 |
663 |
664 | Sections
665 | --------
666 |
667 | ### Add `body` element
668 |
669 | Sometimes `body` element is complemented in unexpected position by a browser.
670 |
671 | Bad:
672 |
673 |
674 |
675 | ...
676 |
677 | ...
678 |
679 |
680 | Good:
681 |
682 |
683 |
684 | ...
685 |
686 |
687 | ...
688 |
689 |
690 |
691 |
692 | ### Forget about `hgroup` element
693 |
694 | W3C spec removes this element.
695 |
696 | Bad:
697 |
698 |
699 | HTML Best Practices
700 | For writing maintainable and scalable HTML documents.
701 |
702 |
703 | Good:
704 |
705 | HTML Best Practices
706 | For writing maintainable and scalable HTML documents.
707 |
708 |
709 | ### Use `address` element only for contact information
710 |
711 | `address` element is for email address, social network account, street address,
712 | telephone number, or something you can get in touch with.
713 |
714 | Bad:
715 |
716 | No rights reserved.
717 |
718 | Good:
719 |
720 | Contact: Kyo Nagashima
721 |
722 |
723 | Grouping content
724 | ----------------
725 |
726 | ### Don’t start with newline in `pre` element
727 |
728 | A first newline will ignored in the browsers, but second and later are rendered.
729 |
730 | Bad:
731 |
732 |
733 | <!DOCTYPE html>
734 |
735 |
736 | Good:
737 |
738 | <!DOCTYPE html>
739 |
740 |
741 |
742 | ### Use appropriate element in `blockquote` element
743 |
744 | `blockquote` element’s content is a quote, not a chunks of characters.
745 |
746 | Bad:
747 |
748 | For writing maintainable and scalable HTML documents.
749 |
750 | Good:
751 |
752 |
753 | For writing maintainable and scalable HTML documents.
754 |
755 |
756 |
757 | ### Don’t include attribution directly in `blockquote` element
758 |
759 | `blockquote` element’s content is a quote.
760 |
761 | Bad:
762 |
763 |
764 | For writing maintainable and scalable HTML documents.
765 |
766 | — HTML Best Practices
767 |
768 |
769 | Good:
770 |
771 |
772 | For writing maintainable and scalable HTML documents.
773 |
774 |
775 | — HTML Best Practices
776 |
777 | Also good (recommended by WHATWG):
778 |
779 |
780 |
781 | For writing maintainable and scalable HTML documents.
782 |
783 |
784 | — HTML Best Practices
785 |
786 |
787 | Also good too (recommended by W3C):
788 |
789 |
790 | For writing maintainable and scalable HTML documents.
791 |
792 |
793 |
794 |
795 |
796 | ### Write one list item per line
797 |
798 | Looooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooong
799 | line is hard toooooooooooooooooooooooooooooooooooooooooooooooooooooooooooo read.
800 |
801 | Bad:
802 |
803 |
804 | General The root Element Sections ...
805 |
806 |
807 | Good:
808 |
809 |
810 | General
811 | The root Element
812 | Sections
813 | ...
814 |
815 |
816 |
817 | ### Use `type` attribute for `ol` element
818 |
819 | Sometimes marker referenced by the contents in the near. If you change marker
820 | with `type` attribute, you will be safe to reference.
821 |
822 | Bad:
823 |
824 |
825 |
830 |
831 |
832 |
833 | General
834 | The root Element
835 | Sections
836 | ...
837 |
838 |
839 |
840 | Good:
841 |
842 |
843 |
844 | General
845 | The root Element
846 | Sections
847 | ...
848 |
849 |
850 |
851 |
852 | ### Don’t use `dl` for dialogue
853 |
854 | `dl` element is restricted to an association list in HTML5.
855 |
856 | Bad:
857 |
858 |
859 | Costello
860 | Look, you gotta first baseman?
861 | Abbott
862 | Certainly.
863 | Costello
864 | Who’s playing first?
865 | Abbott
866 | That’s right.
867 | Costello becomes exasperated.
868 | Costello
869 | When you pay off the first baseman every month, who gets the money?
870 | Abbott
871 | Every dollar of it.
872 |
873 |
874 | Good:
875 |
876 | Costello: Look, you gotta first baseman?
877 | Abbott: Certainly.
878 | Costello: Who’s playing first?
879 | Abbott: That’s right.
880 | Costello becomes exasperated.
881 | Costello: When you pay off the first baseman every month, who gets the money?
882 | Abbott: Every dollar of it.
883 |
884 |
885 | ### Place `figcaption` element as first or last child of `figure` element
886 |
887 | Spec (WHATWG version) disallows `figcaption` element in the middle of `figure`
888 | element.
889 |
890 | Bad:
891 |
892 |
893 |
894 | “HTML Best Practices” Cover Art
895 |
896 |
897 |
898 | Good:
899 |
900 |
901 |
902 |
903 | “HTML Best Practices” Cover Art
904 |
905 |
906 |
907 | ### Use `main` element
908 |
909 | `main` element can be used wrapping contents.
910 |
911 | Bad:
912 |
913 |
914 | ...
915 |
916 |
917 | Good:
918 |
919 |
920 | ...
921 |
922 |
923 |
924 | ### Avoid `div` element as much as possible
925 |
926 | `div` element is an element of last resort.
927 |
928 | Bad:
929 |
930 |
931 | ...
932 |
933 |
934 | Good:
935 |
936 |
939 |
940 |
941 | Text-level semantics
942 | --------------------
943 |
944 | ### Don’t split same link that can be grouped
945 |
946 | `a` element can wrap almost all elements (except interactive elements like form
947 | controls and `a` element itself).
948 |
949 | Bad:
950 |
951 |
952 |
953 | A community maintaining and evolving HTML since 2004.
954 |
955 | Good:
956 |
957 |
958 | WHATWG
959 |
960 | A community maintaining and evolving HTML since 2004.
961 |
962 |
963 |
964 | ### Use `download` attribute for downloading a resource
965 |
966 | It will force browsers to download linked resource to the storage.
967 |
968 | Bad:
969 |
970 | offline version
971 |
972 | Good:
973 |
974 | offline version
975 |
976 |
977 | ### Use `rel`, `hreflang`, and `type` attribute if needed
978 |
979 | These hints helps applications how handle linked resource.
980 |
981 | Bad:
982 |
983 | Japanese PDF version
984 |
985 | Good:
986 |
987 | Japanese PDF version
988 |
989 |
990 | ### Clear link text
991 |
992 | Link text should be the label of its linked resource.
993 |
994 | Bad:
995 |
996 | Click here to view PDF version.
997 |
998 | Good:
999 |
1000 | PDF version is also available.
1001 |
1002 |
1003 | ### Don’t use `em` element for warning or caution
1004 |
1005 | These are seriousness. So, `strong` element is more appropriate.
1006 |
1007 | Bad:
1008 |
1009 | Caution!
1010 |
1011 | Good:
1012 |
1013 | Caution!
1014 |
1015 |
1016 | ### Avoid `s`, `i`, `b`, and `u` element as much as possible
1017 |
1018 | These elements’ semantics is too difficult to humans.
1019 |
1020 | Bad:
1021 |
1022 |
1023 |
1024 | Good:
1025 |
1026 |
1027 |
1028 |
1029 | ### Don’t put quotes to `q` element
1030 |
1031 | Quotes are provided by the browser.
1032 |
1033 | Bad:
1034 |
1035 | “For writing maintainable and scalable HTML documents”
1036 |
1037 | Good:
1038 |
1039 | For writing maintainable and scalable HTML documents
1040 |
1041 | Also good:
1042 |
1043 | “For writing maintainable and scalable HTML documents”
1044 |
1045 |
1046 | ### Add `title` attribute to `abbr` element
1047 |
1048 | There is no other way to represent its expansion.
1049 |
1050 | Bad:
1051 |
1052 | HBP
1053 |
1054 | Good:
1055 |
1056 | HBP
1057 |
1058 |
1059 | ### Markup `ruby` element verbosely
1060 |
1061 | `ruby` element support is not completed across the modern browsers.
1062 |
1063 | Bad:
1064 |
1065 | HTMLえいちてぃーえむえる
1066 |
1067 | Good:
1068 |
1069 | HTML ( えいちてぃーえむえる )
1070 |
1071 |
1072 | ### Add `datetime` attribute to non-machine-readable `time` element
1073 |
1074 | When `datetime` attribute does not present, the format of `time` element’s
1075 | content is restricted.
1076 |
1077 | Bad:
1078 |
1079 | Dec 19, 2014
1080 |
1081 | Good:
1082 |
1083 | Dec 19, 2014
1084 |
1085 |
1086 | ### Specify code language with `class` attribute prefixed with `language-`
1087 |
1088 | This is not a formal way, but spec mentions this.
1089 |
1090 | Bad:
1091 |
1092 | <!DOCTYPE html>
1093 |
1094 | Good:
1095 |
1096 | <!DOCTYPE html>
1097 |
1098 |
1099 | ### Keep `kbd` element as simple as possible
1100 |
1101 | Nesting `kbd` element is too difficult to humans.
1102 |
1103 | Bad:
1104 |
1105 | Ctrl +F5
1106 |
1107 | Good:
1108 |
1109 | Ctrl+F5
1110 |
1111 |
1112 | ### Avoid `span` element as much as possible
1113 |
1114 | `span` element is an element of last resort.
1115 |
1116 | Bad:
1117 |
1118 | HTML Best Practices
1119 |
1120 | Good:
1121 |
1122 | HTML Best Practices
1123 |
1124 |
1125 | ### Break after `br` element
1126 |
1127 | Line break should be needed where `br` element is used.
1128 |
1129 | Bad:
1130 |
1131 | HTML Best Practices
1132 |
1133 | Good:
1134 |
1135 | HTML
1136 | Best
1137 | Practices
1138 |
1139 |
1140 | ### Don’t use `br` element only for presentational purpose
1141 |
1142 | `br` element is not for line breaking, it is for line breaks in the contents.
1143 |
1144 | Bad:
1145 |
1146 | Rule name:
1147 | Rule description:
1148 |
1149 |
1150 | Good:
1151 |
1152 | Rule name:
1153 | Rule description:
1154 |
1155 |
1156 |
1157 | Edits
1158 | -----
1159 |
1160 | ### Don’t stride `ins` and `del` element over other elements
1161 |
1162 | Elements cannot be overflow other elements.
1163 |
1164 | Bad:
1165 |
1166 | For writing maintainable and scalable HTML documents. And for mental stability.
1167 |
1168 | Don’t trust!
1169 |
1170 | Good:
1171 |
1172 | For writing maintainable and scalable HTML documents. And for mental stability.
1173 |
1174 | Don’t trust!
1175 |
1176 |
1177 | Embedded content
1178 | ----------------
1179 |
1180 | ### Provide fallback `img` element for `picture` element
1181 |
1182 | The support of `picture` element is not good yet.
1183 |
1184 | Bad:
1185 |
1186 |
1187 |
1188 |
1189 |
1190 |
1191 |
1192 |
1193 | Good:
1194 |
1195 |
1196 |
1197 |
1198 |
1199 |
1200 |
1201 |
1202 |
1203 | ### Add `alt` attrbute to `img` element if needed
1204 |
1205 | `alt` attribute helps those who cannot process images or have image loading
1206 | disabled.
1207 |
1208 | Bad:
1209 |
1210 |
1211 |
1212 | Good:
1213 |
1214 |
1215 |
1216 |
1217 | ### Empty `alt` attribute if possible
1218 |
1219 | If the image is supplemental, there is equivalent content somewhere in the near.
1220 |
1221 | Bad:
1222 |
1223 | Help
1224 |
1225 | Good:
1226 |
1227 | Help
1228 |
1229 |
1230 | ### Omit `alt` attribute if possible
1231 |
1232 | Sometimes you don’t know what text is suitable for `alt` attribute.
1233 |
1234 | Bad:
1235 |
1236 |
1237 |
1238 | Good:
1239 |
1240 |
1241 | (If you cannot see the image, you can use an audio test instead.)
1242 |
1243 |
1244 | ### Empty `iframe` element
1245 |
1246 | There is some restriction in its content. Being empty is always safe.
1247 |
1248 | Bad:
1249 |
1250 |
1253 |
1254 | Good:
1255 |
1256 |
1257 |
1258 |
1259 | ### Markup `map` element content
1260 |
1261 | This content presents to a screen reader.
1262 |
1263 | Bad:
1264 |
1265 |
1266 | General
1267 | |
1268 | The root element
1269 | |
1270 | Sections
1271 |
1272 |
1273 |
1274 | Good:
1275 |
1276 |
1277 |
1278 | General
1279 | |
1280 | The root element
1281 | |
1282 | Sections
1283 |
1284 |
1285 |
1286 |
1287 |
1288 | ### Provide fallback content for `audio` or `video` element
1289 |
1290 | Fallback content is needed for newly introduced elements in HTML5.
1291 |
1292 | Bad:
1293 |
1294 |
1295 |
1296 |
1297 | ...
1298 |
1299 |
1300 | Good:
1301 |
1302 |
1303 |
1304 |
1305 | ...
1306 |
1307 |
1308 |
1309 |
1310 | Tabular data
1311 | ------------
1312 |
1313 | ### Write one cell per line
1314 |
1315 | Long lines are hard to scan.
1316 |
1317 | Bad:
1318 |
1319 |
1320 | General The root Element Sections
1321 |
1322 |
1323 | Good:
1324 |
1325 |
1326 | General
1327 | The root Element
1328 | Sections
1329 |
1330 |
1331 |
1332 | ### Use `th` element for header cell
1333 |
1334 | There is no reason to avoid this.
1335 |
1336 | Bad:
1337 |
1338 |
1339 |
1340 |
1341 | Element
1342 | Empty
1343 | Tag omission
1344 |
1345 |
1346 |
1347 |
1348 | pre
1349 | No
1350 | Neither tag is omissible
1351 |
1352 |
1353 | img
1354 | Yes
1355 | No end tag
1356 |
1357 |
1358 |
1359 |
1360 | Good:
1361 |
1362 |
1363 |
1364 |
1365 | Element
1366 | Empty
1367 | Tag omission
1368 |
1369 |
1370 |
1371 |
1372 | pre
1373 | No
1374 | Neither tag is omissible
1375 |
1376 |
1377 | img
1378 | Yes
1379 | No end tag
1380 |
1381 |
1382 |
1383 |
1384 |
1385 | Forms
1386 | -----
1387 |
1388 | ### Wrap form control with `label` element
1389 |
1390 | `label` element helps focusing form element.
1391 |
1392 | Bad:
1393 |
1394 | Query:
1395 |
1396 | Good:
1397 |
1398 | Query:
1399 |
1400 |
1401 | ### Omit `for` attribute if possible
1402 |
1403 | `label` element can contain some form elements.
1404 |
1405 | Bad:
1406 |
1407 | Query:
1408 |
1409 | Good:
1410 |
1411 | Query:
1412 |
1413 |
1414 | ### Use appropriate `type` attribute for `input` element
1415 |
1416 | With appropriate `type`, browsers gives a tiny features to the `input` element.
1417 |
1418 | Bad:
1419 |
1420 | Search keyword:
1421 |
1422 | Good:
1423 |
1424 | Search keyword:
1425 |
1426 |
1427 | ### Add `value` attribute to `input type="submit"`
1428 |
1429 | The default label for submit button is not standarized across the browser and
1430 | languages.
1431 |
1432 | Bad:
1433 |
1434 |
1435 |
1436 | Good:
1437 |
1438 |
1439 |
1440 |
1441 | ### Add `title` attribute to `input` element when there is `pattern` attribute
1442 |
1443 | If input text does not match to `pattern` attribute, the value of `title`
1444 | attribute will be display as a hint.
1445 |
1446 | Bad:
1447 |
1448 |
1449 |
1450 | Good:
1451 |
1452 |
1453 |
1454 |
1455 | ### Don’t use `placeholder` attribute for labeling
1456 |
1457 | `label` element is for a label, `placeholder` attribute is for a short hint.
1458 |
1459 | Bad:
1460 |
1461 |
1462 |
1463 | Good:
1464 |
1465 | Email:
1466 |
1467 |
1468 | ### Write one `option` element per line
1469 |
1470 | Long lines are hard to scan.
1471 |
1472 | Bad:
1473 |
1474 |
1475 |
1476 |
1477 |
1478 | Good:
1479 |
1480 |
1481 |
1482 |
1483 |
1484 |
1485 |
1486 |
1487 | ### Add `max` attribute to `progress` element
1488 |
1489 | With `max` attribute, the `value` attribute can be write in an easy format.
1490 |
1491 | Bad:
1492 |
1493 | 50%
1494 |
1495 | Good:
1496 |
1497 | 50%
1498 |
1499 |
1500 | ### Add `min` and `max` attribute to `meter` element
1501 |
1502 | With `min` and `max` attribute, the `value` attribute can be write in an easy
1503 | format.
1504 |
1505 | Bad:
1506 |
1507 | 512GB used (1024GB total)
1508 |
1509 | Good:
1510 |
1511 | 512GB used (1024GB total)
1512 |
1513 |
1514 | ### Place `legend` element as the first child of `fieldset` element
1515 |
1516 | Spec requires this.
1517 |
1518 | Bad:
1519 |
1520 |
1521 | Is this section is useful?:
1522 | ...
1523 | About "General"
1524 |
1525 |
1526 | Good:
1527 |
1528 |
1529 | About "General"
1530 | Is this section is useful?:
1531 | ...
1532 |
1533 |
1534 |
1535 | Scripting
1536 | ---------
1537 |
1538 | ### Omit `type` attribute for JavaScript
1539 |
1540 | In HTML5, the default `type` attribute’s value of `script` element is
1541 | `text/javascript`.
1542 |
1543 | Bad:
1544 |
1545 |
1548 |
1549 | Good:
1550 |
1551 |
1554 |
1555 |
1556 | ### Don’t comment out contents of `script` element
1557 |
1558 | This ritual is for the old browser.
1559 |
1560 | Bad:
1561 |
1562 |
1567 |
1568 | Also bad:
1569 |
1570 |
1575 |
1576 | Good:
1577 |
1578 |
1581 |
1582 |
1583 | ### Don’t use script-injected `script` element
1584 |
1585 | `async` attribute is the best for both simplicity and performance.
1586 |
1587 | Bad:
1588 |
1589 |
1595 |
1596 | Good:
1597 |
1598 |
1599 |
1600 |
1601 | Other
1602 | -----
1603 |
1604 | ### Indent consistently
1605 |
1606 | Indentation is important for readability.
1607 |
1608 | Bad:
1609 |
1610 |
1611 |
1612 | ...
1613 |
1614 |
1615 | ...
1616 |
1617 |
1618 |
1619 | Good:
1620 |
1621 |
1622 |
1623 | ...
1624 |
1625 |
1626 | ...
1627 |
1628 |
1629 |
1630 |
1631 | ### Use absolute path for internal links
1632 |
1633 | An absolute path works better on your localhost without internet connection.
1634 |
1635 | Bad:
1636 |
1637 |
1638 | ...
1639 | You can find more at contact page .
1640 |
1641 | Good:
1642 |
1643 |
1644 | ...
1645 | You can find more at contact page .
1646 |
1647 |
1648 | Contributors
1649 | ------------
1650 |
1651 | - [@hail2u]
1652 | - [@momdo]
1653 | - [@techhtml]
1654 |
1655 |
1656 | License
1657 | -------
1658 |
1659 | [CC0]
1660 |
1661 |
1662 | [@hail2u]: https://github.com/hail2u
1663 | [@momdo]: https://github.com/momdo
1664 | [@techhtml]: https://github.com/techhtml
1665 | [CC0]: http://creativecommons.org/publicdomain/zero/1.0/
1666 |
--------------------------------------------------------------------------------
/README.ja.md:
--------------------------------------------------------------------------------
1 | Translations: [English (en)](README.md) · [日本語 (ja)](README.ja.md) · [한국어 (ko)](README.ko.md)
2 |
3 | 普通のHTMLの書き方
4 | ==================
5 |
6 | 保守しやすく、規模に依存しないHTML文書のために
7 |
8 |
9 |
10 | * [一般](#%E4%B8%80%E8%88%AC)
11 | * [DOCTYPEで始める](#doctype%E3%81%A7%E5%A7%8B%E3%82%81%E3%82%8B)
12 | * [置き換えられるべきまたは旧式のDOCTYPEを使わない](#%E7%BD%AE%E3%81%8D%E6%8F%9B%E3%81%88%E3%82%89%E3%82%8C%E3%82%8B%E3%81%B9%E3%81%8D%E3%81%BE%E3%81%9F%E3%81%AF%E6%97%A7%E5%BC%8F%E3%81%AEdoctype%E3%82%92%E4%BD%BF%E3%82%8F%E3%81%AA%E3%81%84)
13 | * [XML宣言を使用しない](#xml%E5%AE%A3%E8%A8%80%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%AA%E3%81%84)
14 | * [文字参照はできる限り使わない](#%E6%96%87%E5%AD%97%E5%8F%82%E7%85%A7%E3%81%AF%E3%81%A7%E3%81%8D%E3%82%8B%E9%99%90%E3%82%8A%E4%BD%BF%E3%82%8F%E3%81%AA%E3%81%84)
15 | * [`&`と`<`、`>`、`"`、`'`は名前文字参照を使ってエスケープする](#%E3%81%A8%E3%81%AF%E5%90%8D%E5%89%8D%E6%96%87%E5%AD%97%E5%8F%82%E7%85%A7%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%A6%E3%82%A8%E3%82%B9%E3%82%B1%E3%83%BC%E3%83%97%E3%81%99%E3%82%8B)
16 | * [制御文字や不可視文字は数値文字参照を使う](#%E5%88%B6%E5%BE%A1%E6%96%87%E5%AD%97%E3%82%84%E4%B8%8D%E5%8F%AF%E8%A6%96%E6%96%87%E5%AD%97%E3%81%AF%E6%95%B0%E5%80%A4%E6%96%87%E5%AD%97%E5%8F%82%E7%85%A7%E3%82%92%E4%BD%BF%E3%81%86)
17 | * [コメントではその内容の前後へ空白文字を置く](#%E3%82%B3%E3%83%A1%E3%83%B3%E3%83%88%E3%81%A7%E3%81%AF%E3%81%9D%E3%81%AE%E5%86%85%E5%AE%B9%E3%81%AE%E5%89%8D%E5%BE%8C%E3%81%B8%E7%A9%BA%E7%99%BD%E6%96%87%E5%AD%97%E3%82%92%E7%BD%AE%E3%81%8F)
18 | * [終了タグを省略しない](#%E7%B5%82%E4%BA%86%E3%82%BF%E3%82%B0%E3%82%92%E7%9C%81%E7%95%A5%E3%81%97%E3%81%AA%E3%81%84)
19 | * [空要素の書き方を混ぜない](#%E7%A9%BA%E8%A6%81%E7%B4%A0%E3%81%AE%E6%9B%B8%E3%81%8D%E6%96%B9%E3%82%92%E6%B7%B7%E3%81%9C%E3%81%AA%E3%81%84)
20 | * [タグや属性値の前後へ空白文字を置かない](#%E3%82%BF%E3%82%B0%E3%82%84%E5%B1%9E%E6%80%A7%E5%80%A4%E3%81%AE%E5%89%8D%E5%BE%8C%E3%81%B8%E7%A9%BA%E7%99%BD%E6%96%87%E5%AD%97%E3%82%92%E7%BD%AE%E3%81%8B%E3%81%AA%E3%81%84)
21 | * [大文字・小文字を混ぜない](#%E5%A4%A7%E6%96%87%E5%AD%97%E5%B0%8F%E6%96%87%E5%AD%97%E3%82%92%E6%B7%B7%E3%81%9C%E3%81%AA%E3%81%84)
22 | * [引用符を混ぜない](#%E5%BC%95%E7%94%A8%E7%AC%A6%E3%82%92%E6%B7%B7%E3%81%9C%E3%81%AA%E3%81%84)
23 | * [属性を2文字以上の空白文字で区切らない](#%E5%B1%9E%E6%80%A7%E3%82%922%E6%96%87%E5%AD%97%E4%BB%A5%E4%B8%8A%E3%81%AE%E7%A9%BA%E7%99%BD%E6%96%87%E5%AD%97%E3%81%A7%E5%8C%BA%E5%88%87%E3%82%89%E3%81%AA%E3%81%84)
24 | * [真偽値を取る属性の値は省略する](#%E7%9C%9F%E5%81%BD%E5%80%A4%E3%82%92%E5%8F%96%E3%82%8B%E5%B1%9E%E6%80%A7%E3%81%AE%E5%80%A4%E3%81%AF%E7%9C%81%E7%95%A5%E3%81%99%E3%82%8B)
25 | * [名前空間は省略する](#%E5%90%8D%E5%89%8D%E7%A9%BA%E9%96%93%E3%81%AF%E7%9C%81%E7%95%A5%E3%81%99%E3%82%8B)
26 | * [XML属性は使わない](#xml%E5%B1%9E%E6%80%A7%E3%81%AF%E4%BD%BF%E3%82%8F%E3%81%AA%E3%81%84)
27 | * [`data-*`とMicrodata、RDFa Lite用の属性と通常の属性を混ぜない](#data-%E3%81%A8microdatardfa-lite%E7%94%A8%E3%81%AE%E5%B1%9E%E6%80%A7%E3%81%A8%E9%80%9A%E5%B8%B8%E3%81%AE%E5%B1%9E%E6%80%A7%E3%82%92%E6%B7%B7%E3%81%9C%E3%81%AA%E3%81%84)
28 | * [デフォルトの暗黙的なARIAセマンティックを尊重する](#%E3%83%87%E3%83%95%E3%82%A9%E3%83%AB%E3%83%88%E3%81%AE%E6%9A%97%E9%BB%99%E7%9A%84%E3%81%AAaria%E3%82%BB%E3%83%9E%E3%83%B3%E3%83%86%E3%82%A3%E3%83%83%E3%82%AF%E3%82%92%E5%B0%8A%E9%87%8D%E3%81%99%E3%82%8B)
29 | * [文書要素](#%E6%96%87%E6%9B%B8%E8%A6%81%E7%B4%A0)
30 | * [`lang`属性を追加する](#lang%E5%B1%9E%E6%80%A7%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%99%E3%82%8B)
31 | * [`lang`属性の値はできる限り短くする](#lang%E5%B1%9E%E6%80%A7%E3%81%AE%E5%80%A4%E3%81%AF%E3%81%A7%E3%81%8D%E3%82%8B%E9%99%90%E3%82%8A%E7%9F%AD%E3%81%8F%E3%81%99%E3%82%8B)
32 | * [できる限り`data-*`属性は避ける](#%E3%81%A7%E3%81%8D%E3%82%8B%E9%99%90%E3%82%8Adata-%E5%B1%9E%E6%80%A7%E3%81%AF%E9%81%BF%E3%81%91%E3%82%8B)
33 | * [文書メタデータ](#%E6%96%87%E6%9B%B8%E3%83%A1%E3%82%BF%E3%83%87%E3%83%BC%E3%82%BF)
34 | * [`title`要素を書く](#title%E8%A6%81%E7%B4%A0%E3%82%92%E6%9B%B8%E3%81%8F)
35 | * [`base`要素を使わない](#base%E8%A6%81%E7%B4%A0%E3%82%92%E4%BD%BF%E3%82%8F%E3%81%AA%E3%81%84)
36 | * [マイナーな参照先リソースのMIMEタイプを指定する](#%E3%83%9E%E3%82%A4%E3%83%8A%E3%83%BC%E3%81%AA%E5%8F%82%E7%85%A7%E5%85%88%E3%83%AA%E3%82%BD%E3%83%BC%E3%82%B9%E3%81%AEmime%E3%82%BF%E3%82%A4%E3%83%97%E3%82%92%E6%8C%87%E5%AE%9A%E3%81%99%E3%82%8B)
37 | * [`favicon.ico`へリンクしない](#faviconico%E3%81%B8%E3%83%AA%E3%83%B3%E3%82%AF%E3%81%97%E3%81%AA%E3%81%84)
38 | * [代替スタイルシートへ`title`属性を追加する](#%E4%BB%A3%E6%9B%BF%E3%82%B9%E3%82%BF%E3%82%A4%E3%83%AB%E3%82%B7%E3%83%BC%E3%83%88%E3%81%B8title%E5%B1%9E%E6%80%A7%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%99%E3%82%8B)
39 | * [URLには`link`要素を使う](#url%E3%81%AB%E3%81%AFlink%E8%A6%81%E7%B4%A0%E3%82%92%E4%BD%BF%E3%81%86)
40 | * [文書の文字エンコーディングを指定する](#%E6%96%87%E6%9B%B8%E3%81%AE%E6%96%87%E5%AD%97%E3%82%A8%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%87%E3%82%A3%E3%83%B3%E3%82%B0%E3%82%92%E6%8C%87%E5%AE%9A%E3%81%99%E3%82%8B)
41 | * [置き換えられるべき文字エンコーディング指定フォーマットを使わない](#%E7%BD%AE%E3%81%8D%E6%8F%9B%E3%81%88%E3%82%89%E3%82%8C%E3%82%8B%E3%81%B9%E3%81%8D%E6%96%87%E5%AD%97%E3%82%A8%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%87%E3%82%A3%E3%83%B3%E3%82%B0%E6%8C%87%E5%AE%9A%E3%83%95%E3%82%A9%E3%83%BC%E3%83%9E%E3%83%83%E3%83%88%E3%82%92%E4%BD%BF%E3%82%8F%E3%81%AA%E3%81%84)
42 | * [最初に文字エンコーディングを指定する](#%E6%9C%80%E5%88%9D%E3%81%AB%E6%96%87%E5%AD%97%E3%82%A8%E3%83%B3%E3%82%B3%E3%83%BC%E3%83%87%E3%82%A3%E3%83%B3%E3%82%B0%E3%82%92%E6%8C%87%E5%AE%9A%E3%81%99%E3%82%8B)
43 | * [UTF-8を使う](#utf-8%E3%82%92%E4%BD%BF%E3%81%86)
44 | * [CSSの`type`属性は省略する](#css%E3%81%AEtype%E5%B1%9E%E6%80%A7%E3%81%AF%E7%9C%81%E7%95%A5%E3%81%99%E3%82%8B)
45 | * [`style`要素の中をコメントアウトしない](#style%E8%A6%81%E7%B4%A0%E3%81%AE%E4%B8%AD%E3%82%92%E3%82%B3%E3%83%A1%E3%83%B3%E3%83%88%E3%82%A2%E3%82%A6%E3%83%88%E3%81%97%E3%81%AA%E3%81%84)
46 | * [CSSとJavaScriptのタグを混ぜない](#css%E3%81%A8javascript%E3%81%AE%E3%82%BF%E3%82%B0%E3%82%92%E6%B7%B7%E3%81%9C%E3%81%AA%E3%81%84)
47 | * [セクション](#%E3%82%BB%E3%82%AF%E3%82%B7%E3%83%A7%E3%83%B3)
48 | * [`body`要素を書く](#body%E8%A6%81%E7%B4%A0%E3%82%92%E6%9B%B8%E3%81%8F)
49 | * [`hgroup`要素のことは忘れる](#hgroup%E8%A6%81%E7%B4%A0%E3%81%AE%E3%81%93%E3%81%A8%E3%81%AF%E5%BF%98%E3%82%8C%E3%82%8B)
50 | * [`address`要素は連絡先情報にのみ使う](#address%E8%A6%81%E7%B4%A0%E3%81%AF%E9%80%A3%E7%B5%A1%E5%85%88%E6%83%85%E5%A0%B1%E3%81%AB%E3%81%AE%E3%81%BF%E4%BD%BF%E3%81%86)
51 | * [グルーピングコンテンツ](#%E3%82%B0%E3%83%AB%E3%83%BC%E3%83%94%E3%83%B3%E3%82%B0%E3%82%B3%E3%83%B3%E3%83%86%E3%83%B3%E3%83%84)
52 | * [`pre`要素は改行で始めない](#pre%E8%A6%81%E7%B4%A0%E3%81%AF%E6%94%B9%E8%A1%8C%E3%81%A7%E5%A7%8B%E3%82%81%E3%81%AA%E3%81%84)
53 | * [`blockquote`要素内でも適切な要素を使う](#blockquote%E8%A6%81%E7%B4%A0%E5%86%85%E3%81%A7%E3%82%82%E9%81%A9%E5%88%87%E3%81%AA%E8%A6%81%E7%B4%A0%E3%82%92%E4%BD%BF%E3%81%86)
54 | * [`blockquote`要素内に帰属情報を含めない](#blockquote%E8%A6%81%E7%B4%A0%E5%86%85%E3%81%AB%E5%B8%B0%E5%B1%9E%E6%83%85%E5%A0%B1%E3%82%92%E5%90%AB%E3%82%81%E3%81%AA%E3%81%84)
55 | * [リスト項目は1行に1つずつ書く](#%E3%83%AA%E3%82%B9%E3%83%88%E9%A0%85%E7%9B%AE%E3%81%AF1%E8%A1%8C%E3%81%AB1%E3%81%A4%E3%81%9A%E3%81%A4%E6%9B%B8%E3%81%8F)
56 | * [`ol`要素では`type`属性を使う](#ol%E8%A6%81%E7%B4%A0%E3%81%A7%E3%81%AFtype%E5%B1%9E%E6%80%A7%E3%82%92%E4%BD%BF%E3%81%86)
57 | * [`dl`を会話のために使わない](#dl%E3%82%92%E4%BC%9A%E8%A9%B1%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AB%E4%BD%BF%E3%82%8F%E3%81%AA%E3%81%84)
58 | * [`figcaption`要素は`figure`要素の最初か最後に置く](#figcaption%E8%A6%81%E7%B4%A0%E3%81%AFfigure%E8%A6%81%E7%B4%A0%E3%81%AE%E6%9C%80%E5%88%9D%E3%81%8B%E6%9C%80%E5%BE%8C%E3%81%AB%E7%BD%AE%E3%81%8F)
59 | * [`main`要素を使う](#main%E8%A6%81%E7%B4%A0%E3%82%92%E4%BD%BF%E3%81%86)
60 | * [できる限り`div`要素は避ける](#%E3%81%A7%E3%81%8D%E3%82%8B%E9%99%90%E3%82%8Adiv%E8%A6%81%E7%B4%A0%E3%81%AF%E9%81%BF%E3%81%91%E3%82%8B)
61 | * [テキストレベルセマンティックス](#%E3%83%86%E3%82%AD%E3%82%B9%E3%83%88%E3%83%AC%E3%83%99%E3%83%AB%E3%82%BB%E3%83%9E%E3%83%B3%E3%83%86%E3%82%A3%E3%83%83%E3%82%AF%E3%82%B9)
62 | * [グループ化できるリンクは分割しない](#%E3%82%B0%E3%83%AB%E3%83%BC%E3%83%97%E5%8C%96%E3%81%A7%E3%81%8D%E3%82%8B%E3%83%AA%E3%83%B3%E3%82%AF%E3%81%AF%E5%88%86%E5%89%B2%E3%81%97%E3%81%AA%E3%81%84)
63 | * [リソースをダウンロードさせる場合は`download`属性を使う](#%E3%83%AA%E3%82%BD%E3%83%BC%E3%82%B9%E3%82%92%E3%83%80%E3%82%A6%E3%83%B3%E3%83%AD%E3%83%BC%E3%83%89%E3%81%95%E3%81%9B%E3%82%8B%E5%A0%B4%E5%90%88%E3%81%AFdownload%E5%B1%9E%E6%80%A7%E3%82%92%E4%BD%BF%E3%81%86)
64 | * [`rel`や`hreflang`、`type`属性を必要ならば使う](#rel%E3%82%84hreflangtype%E5%B1%9E%E6%80%A7%E3%82%92%E5%BF%85%E8%A6%81%E3%81%AA%E3%82%89%E3%81%B0%E4%BD%BF%E3%81%86)
65 | * [リンク文字列は明確にする](#%E3%83%AA%E3%83%B3%E3%82%AF%E6%96%87%E5%AD%97%E5%88%97%E3%81%AF%E6%98%8E%E7%A2%BA%E3%81%AB%E3%81%99%E3%82%8B)
66 | * [`em`要素を警告や注意に使わない](#em%E8%A6%81%E7%B4%A0%E3%82%92%E8%AD%A6%E5%91%8A%E3%82%84%E6%B3%A8%E6%84%8F%E3%81%AB%E4%BD%BF%E3%82%8F%E3%81%AA%E3%81%84)
67 | * [できる限り`s`や`i`、`b`、`u`要素を避ける](#%E3%81%A7%E3%81%8D%E3%82%8B%E9%99%90%E3%82%8As%E3%82%84ibu%E8%A6%81%E7%B4%A0%E3%82%92%E9%81%BF%E3%81%91%E3%82%8B)
68 | * [`q`要素内へ引用符は置かない](#q%E8%A6%81%E7%B4%A0%E5%86%85%E3%81%B8%E5%BC%95%E7%94%A8%E7%AC%A6%E3%81%AF%E7%BD%AE%E3%81%8B%E3%81%AA%E3%81%84)
69 | * [`abbr`要素へ`title`属性を追加する](#abbr%E8%A6%81%E7%B4%A0%E3%81%B8title%E5%B1%9E%E6%80%A7%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%99%E3%82%8B)
70 | * [`ruby`要素は冗長にマークアップする](#ruby%E8%A6%81%E7%B4%A0%E3%81%AF%E5%86%97%E9%95%B7%E3%81%AB%E3%83%9E%E3%83%BC%E3%82%AF%E3%82%A2%E3%83%83%E3%83%97%E3%81%99%E3%82%8B)
71 | * [機械的に解釈可能でない`time`要素では`datetime`属性を追加する](#%E6%A9%9F%E6%A2%B0%E7%9A%84%E3%81%AB%E8%A7%A3%E9%87%88%E5%8F%AF%E8%83%BD%E3%81%A7%E3%81%AA%E3%81%84time%E8%A6%81%E7%B4%A0%E3%81%A7%E3%81%AFdatetime%E5%B1%9E%E6%80%A7%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%99%E3%82%8B)
72 | * [コードの言語は`class`属性で`language-`で始めることで指定する](#%E3%82%B3%E3%83%BC%E3%83%89%E3%81%AE%E8%A8%80%E8%AA%9E%E3%81%AFclass%E5%B1%9E%E6%80%A7%E3%81%A7language-%E3%81%A7%E5%A7%8B%E3%82%81%E3%82%8B%E3%81%93%E3%81%A8%E3%81%A7%E6%8C%87%E5%AE%9A%E3%81%99%E3%82%8B)
73 | * [できる限り`kbd`要素はシンプルにする](#%E3%81%A7%E3%81%8D%E3%82%8B%E9%99%90%E3%82%8Akbd%E8%A6%81%E7%B4%A0%E3%81%AF%E3%82%B7%E3%83%B3%E3%83%97%E3%83%AB%E3%81%AB%E3%81%99%E3%82%8B)
74 | * [できる限り`span`要素は使わない](#%E3%81%A7%E3%81%8D%E3%82%8B%E9%99%90%E3%82%8Aspan%E8%A6%81%E7%B4%A0%E3%81%AF%E4%BD%BF%E3%82%8F%E3%81%AA%E3%81%84)
75 | * [`br`要素の後ろでは改行する](#br%E8%A6%81%E7%B4%A0%E3%81%AE%E5%BE%8C%E3%82%8D%E3%81%A7%E3%81%AF%E6%94%B9%E8%A1%8C%E3%81%99%E3%82%8B)
76 | * [見た目だけのために`br`要素を使わない](#%E8%A6%8B%E3%81%9F%E7%9B%AE%E3%81%A0%E3%81%91%E3%81%AE%E3%81%9F%E3%82%81%E3%81%ABbr%E8%A6%81%E7%B4%A0%E3%82%92%E4%BD%BF%E3%82%8F%E3%81%AA%E3%81%84)
77 | * [編集](#%E7%B7%A8%E9%9B%86)
78 | * [`ins`や`del`要素は他の要素をまたがせない](#ins%E3%82%84del%E8%A6%81%E7%B4%A0%E3%81%AF%E4%BB%96%E3%81%AE%E8%A6%81%E7%B4%A0%E3%82%92%E3%81%BE%E3%81%9F%E3%81%8C%E3%81%9B%E3%81%AA%E3%81%84)
79 | * [エンベディッドコンテンツ](#%E3%82%A8%E3%83%B3%E3%83%99%E3%83%87%E3%82%A3%E3%83%83%E3%83%89%E3%82%B3%E3%83%B3%E3%83%86%E3%83%B3%E3%83%84)
80 | * [`picture`要素ではフォールバックのための`img`要素を提供する](#picture%E8%A6%81%E7%B4%A0%E3%81%A7%E3%81%AF%E3%83%95%E3%82%A9%E3%83%BC%E3%83%AB%E3%83%90%E3%83%83%E3%82%AF%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AEimg%E8%A6%81%E7%B4%A0%E3%82%92%E6%8F%90%E4%BE%9B%E3%81%99%E3%82%8B)
81 | * [必要な時は`img`要素へ`alt`属性を追加する](#%E5%BF%85%E8%A6%81%E3%81%AA%E6%99%82%E3%81%AFimg%E8%A6%81%E7%B4%A0%E3%81%B8alt%E5%B1%9E%E6%80%A7%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%99%E3%82%8B)
82 | * [可能ならば`alt`属性は空にする](#%E5%8F%AF%E8%83%BD%E3%81%AA%E3%82%89%E3%81%B0alt%E5%B1%9E%E6%80%A7%E3%81%AF%E7%A9%BA%E3%81%AB%E3%81%99%E3%82%8B)
83 | * [可能ならば`alt`属性は省略する](#%E5%8F%AF%E8%83%BD%E3%81%AA%E3%82%89%E3%81%B0alt%E5%B1%9E%E6%80%A7%E3%81%AF%E7%9C%81%E7%95%A5%E3%81%99%E3%82%8B)
84 | * [`iframe`要素の中は空にする](#iframe%E8%A6%81%E7%B4%A0%E3%81%AE%E4%B8%AD%E3%81%AF%E7%A9%BA%E3%81%AB%E3%81%99%E3%82%8B)
85 | * [`map`要素の中はマークアップする](#map%E8%A6%81%E7%B4%A0%E3%81%AE%E4%B8%AD%E3%81%AF%E3%83%9E%E3%83%BC%E3%82%AF%E3%82%A2%E3%83%83%E3%83%97%E3%81%99%E3%82%8B)
86 | * [`audio`や`video`要素にフォールバックのためのコンテンツを提供する](#audio%E3%82%84video%E8%A6%81%E7%B4%A0%E3%81%AB%E3%83%95%E3%82%A9%E3%83%BC%E3%83%AB%E3%83%90%E3%83%83%E3%82%AF%E3%81%AE%E3%81%9F%E3%82%81%E3%81%AE%E3%82%B3%E3%83%B3%E3%83%86%E3%83%B3%E3%83%84%E3%82%92%E6%8F%90%E4%BE%9B%E3%81%99%E3%82%8B)
87 | * [テーブルデータ](#%E3%83%86%E3%83%BC%E3%83%96%E3%83%AB%E3%83%87%E3%83%BC%E3%82%BF)
88 | * [1行に1つのセルを書く](#1%E8%A1%8C%E3%81%AB1%E3%81%A4%E3%81%AE%E3%82%BB%E3%83%AB%E3%82%92%E6%9B%B8%E3%81%8F)
89 | * [見出しセルには`th`要素を使う](#%E8%A6%8B%E5%87%BA%E3%81%97%E3%82%BB%E3%83%AB%E3%81%AB%E3%81%AFth%E8%A6%81%E7%B4%A0%E3%82%92%E4%BD%BF%E3%81%86)
90 | * [フォーム](#%E3%83%95%E3%82%A9%E3%83%BC%E3%83%A0)
91 | * [フォームコントロールは`label`要素で括る](#%E3%83%95%E3%82%A9%E3%83%BC%E3%83%A0%E3%82%B3%E3%83%B3%E3%83%88%E3%83%AD%E3%83%BC%E3%83%AB%E3%81%AFlabel%E8%A6%81%E7%B4%A0%E3%81%A7%E6%8B%AC%E3%82%8B)
92 | * [可能ならば`for`属性は省略する](#%E5%8F%AF%E8%83%BD%E3%81%AA%E3%82%89%E3%81%B0for%E5%B1%9E%E6%80%A7%E3%81%AF%E7%9C%81%E7%95%A5%E3%81%99%E3%82%8B)
93 | * [`input`要素では適切な`type`属性を使う](#input%E8%A6%81%E7%B4%A0%E3%81%A7%E3%81%AF%E9%81%A9%E5%88%87%E3%81%AAtype%E5%B1%9E%E6%80%A7%E3%82%92%E4%BD%BF%E3%81%86)
94 | * [`input type="submit"`には`value`属性を追加する](#input-typesubmit%E3%81%AB%E3%81%AFvalue%E5%B1%9E%E6%80%A7%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%99%E3%82%8B)
95 | * [`pattern`属性を持つ`input`要素には`title`属性を追加する](#pattern%E5%B1%9E%E6%80%A7%E3%82%92%E6%8C%81%E3%81%A4input%E8%A6%81%E7%B4%A0%E3%81%AB%E3%81%AFtitle%E5%B1%9E%E6%80%A7%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%99%E3%82%8B)
96 | * [`placeholder`属性をラベル付けに使わない](#placeholder%E5%B1%9E%E6%80%A7%E3%82%92%E3%83%A9%E3%83%99%E3%83%AB%E4%BB%98%E3%81%91%E3%81%AB%E4%BD%BF%E3%82%8F%E3%81%AA%E3%81%84)
97 | * [`option`要素は1行に1つ書く](#option%E8%A6%81%E7%B4%A0%E3%81%AF1%E8%A1%8C%E3%81%AB1%E3%81%A4%E6%9B%B8%E3%81%8F)
98 | * [`progress`要素には`max`属性を追加する](#progress%E8%A6%81%E7%B4%A0%E3%81%AB%E3%81%AFmax%E5%B1%9E%E6%80%A7%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%99%E3%82%8B)
99 | * [`meter`要素では`min`及び`max`属性を追加する](#meter%E8%A6%81%E7%B4%A0%E3%81%A7%E3%81%AFmin%E5%8F%8A%E3%81%B3max%E5%B1%9E%E6%80%A7%E3%82%92%E8%BF%BD%E5%8A%A0%E3%81%99%E3%82%8B)
100 | * [`legend`要素は`fieldset`要素の最初に置く](#legend%E8%A6%81%E7%B4%A0%E3%81%AFfieldset%E8%A6%81%E7%B4%A0%E3%81%AE%E6%9C%80%E5%88%9D%E3%81%AB%E7%BD%AE%E3%81%8F)
101 | * [スクリプティング](#%E3%82%B9%E3%82%AF%E3%83%AA%E3%83%97%E3%83%86%E3%82%A3%E3%83%B3%E3%82%B0)
102 | * [JavaScriptでは`type`属性を省略する](#javascript%E3%81%A7%E3%81%AFtype%E5%B1%9E%E6%80%A7%E3%82%92%E7%9C%81%E7%95%A5%E3%81%99%E3%82%8B)
103 | * [`script`要素の中をコメントアウトしない](#script%E8%A6%81%E7%B4%A0%E3%81%AE%E4%B8%AD%E3%82%92%E3%82%B3%E3%83%A1%E3%83%B3%E3%83%88%E3%82%A2%E3%82%A6%E3%83%88%E3%81%97%E3%81%AA%E3%81%84)
104 | * [`script`要素を動的に生成するテクニックを使わない](#script%E8%A6%81%E7%B4%A0%E3%82%92%E5%8B%95%E7%9A%84%E3%81%AB%E7%94%9F%E6%88%90%E3%81%99%E3%82%8B%E3%83%86%E3%82%AF%E3%83%8B%E3%83%83%E3%82%AF%E3%82%92%E4%BD%BF%E3%82%8F%E3%81%AA%E3%81%84)
105 | * [その他](#%E3%81%9D%E3%81%AE%E4%BB%96)
106 | * [一貫した量でインデントする](#%E4%B8%80%E8%B2%AB%E3%81%97%E3%81%9F%E9%87%8F%E3%81%A7%E3%82%A4%E3%83%B3%E3%83%87%E3%83%B3%E3%83%88%E3%81%99%E3%82%8B)
107 | * [内部リンクには絶対パスを使う](#%E5%86%85%E9%83%A8%E3%83%AA%E3%83%B3%E3%82%AF%E3%81%AB%E3%81%AF%E7%B5%B6%E5%AF%BE%E3%83%91%E3%82%B9%E3%82%92%E4%BD%BF%E3%81%86)
108 | * [投稿者](#%E6%8A%95%E7%A8%BF%E8%80%85)
109 | * [ライセンス](#%E3%83%A9%E3%82%A4%E3%82%BB%E3%83%B3%E3%82%B9)
110 |
111 |
112 |
113 |
114 | 一般
115 | ----
116 |
117 | ### DOCTYPEで始める
118 |
119 | DOCTYPEは標準モードを有効にするために必要です。
120 |
121 | 悪い例:
122 |
123 |
124 | ...
125 |
126 |
127 | 良い例:
128 |
129 |
130 |
131 | ...
132 |
133 |
134 |
135 | ### 置き換えられるべきまたは旧式のDOCTYPEを使わない
136 |
137 | もはやDOCTYPEはDTDのためにあるわけではないので、シンプルにしましょう。
138 |
139 | 悪い例:
140 |
141 |
143 |
144 | 良い例:
145 |
146 |
147 |
148 |
149 | ### XML宣言を使用しない
150 |
151 | まだXHTMLを書きたいんですか?
152 |
153 | 悪い例:
154 |
155 |
156 |
157 |
158 | 良い例:
159 |
160 |
161 |
162 |
163 | ### 文字参照はできる限り使わない
164 |
165 | UTF-8でHTML文書を書くなら、Emojiも含めほとんどあらゆる文字はそのまま書けます。
166 |
167 | 悪い例:
168 |
169 | Copyright © 2014 W3C®
170 |
171 | 良い例:
172 |
173 | Copyright © 2014 W3C®
174 |
175 |
176 | ### `&`と`<`、`>`、`"`、`'`は名前文字参照を使ってエスケープする
177 |
178 | バグのないHTML文書を作成するためには、これらの文字は常にエスケープされるべきです。
179 |
180 | 悪い例:
181 |
182 | The "&" character
183 |
184 | 良い例:
185 |
186 | The "&" character
187 |
188 |
189 | ### 制御文字や不可視文字は数値文字参照を使う
190 |
191 | これらの文字は簡単に他の文字と間違えられてしまいます。また仕様では、これらの文字へ人間にわかりやすい名前を付けていることを保証していません。
192 |
193 | 悪い例:
194 |
195 | This book can read in 1 hour.
196 |
197 | 良い例:
198 |
199 | This book can read in 1 hour.
200 |
201 |
202 | ### コメントではその内容の前後へ空白文字を置く
203 |
204 | いくつかの文字はコメントの開始タグの直後や終了タグの直前に書くことができません。
205 |
206 | 悪い例:
207 |
208 |
209 |
210 | 良い例:
211 |
212 |
213 |
214 |
215 | ### 終了タグを省略しない
216 |
217 | 多分、あなたは終了タグを省略するためのルールを理解していないでしょう。
218 |
219 | 悪い例:
220 |
221 |
222 |
223 | ...
224 |
225 | 良い例:
226 |
227 |
228 |
229 | ...
230 |
231 |
232 |
233 |
234 | ### 空要素の書き方を混ぜない
235 |
236 | 一貫性は読みやすさのキーポイントです。
237 |
238 | 悪い例:
239 |
240 |
241 |
242 |
243 | 良い例:
244 |
245 |
246 |
247 |
248 |
249 | ### タグや属性値の前後へ空白文字を置かない
250 |
251 | そうする必要はまったくありません。
252 |
253 | 悪い例:
254 |
255 | HTML Best Practices
256 |
257 | 良い例:
258 |
259 | HTML Best Practices
260 |
261 |
262 | ### 大文字・小文字を混ぜない
263 |
264 | これも一貫性を与えてくれます。
265 |
266 | 悪い例:
267 |
268 | General
269 |
270 | 良い例:
271 |
272 | General
273 |
274 | 同じく良い例:
275 |
276 | General
277 |
278 |
279 | ### 引用符を混ぜない
280 |
281 | 上に同じです。
282 |
283 | 悪い例:
284 |
285 |
286 |
287 | 良い例:
288 |
289 |
290 |
291 |
292 | ### 属性を2文字以上の空白文字で区切らない
293 |
294 | あなたのよくわからない整形ルールは誰かを混乱させます。
295 |
296 | 悪い例:
297 |
298 |
299 |
300 | 良い例:
301 |
302 |
303 |
304 |
305 | ### 真偽値を取る属性の値は省略する
306 |
307 | この方が簡単に書けますよね?
308 |
309 | 悪い例:
310 |
311 |
312 |
313 | 良い例:
314 |
315 |
316 |
317 |
318 | ### 名前空間は省略する
319 |
320 | SVGやMathMLはHTML5の文書では直接扱えます。
321 |
322 | 悪い例:
323 |
324 |
325 | ...
326 |
327 |
328 | 良い例:
329 |
330 |
331 | ...
332 |
333 |
334 |
335 | ### XML属性は使わない
336 |
337 | 我々はHTML文書を書いています。
338 |
339 | 悪い例:
340 |
341 | ...
342 |
343 | 良い例:
344 |
345 | ...
346 |
347 |
348 | ### `data-*`とMicrodata、RDFa Lite用の属性と通常の属性を混ぜない
349 |
350 | タグ文字列はとても複雑になりえます。こういった簡単なルールによってタグ文字列を読みやすくできるでしょう。
351 |
352 | 悪い例:
353 |
354 |
355 |
356 | 良い例:
357 |
358 |
359 |
360 |
361 | ### デフォルトの暗黙的なARIAセマンティックを尊重する
362 |
363 | いくつかの要素はHTML文章において暗黙的にARIA `role`を持っているので、それは指定しないようにしましょう。
364 |
365 | 悪い例:
366 |
367 |
368 | ...
369 |
370 |
371 |
372 |
373 | 良い例:
374 |
375 |
376 | ...
377 |
378 |
379 |
380 |
381 |
382 | 文書要素
383 | --------
384 |
385 | ### `lang`属性を追加する
386 |
387 | `lang`属性はHTML文書の翻訳に役立ちます。
388 |
389 | 悪い例:
390 |
391 |
392 |
393 | 良い例:
394 |
395 |
396 |
397 |
398 | ### `lang`属性の値はできる限り短くする
399 |
400 | 日本語は日本でのみ使われます。つまり国コードは必要ありません。
401 |
402 | 悪い例:
403 |
404 |
405 |
406 | 良い例:
407 |
408 |
409 |
410 |
411 | ### できる限り`data-*`属性は避ける
412 |
413 | 適切な属性は、ブラウザーがうまく扱ってくれるかもしれません。
414 |
415 | 悪い例:
416 |
417 | chemises
418 | ...
419 | Do not wash!
420 |
421 | 良い例:
422 |
423 | chemises
424 | ...
425 | Do not wash!
426 |
427 |
428 | 文書メタデータ
429 | --------------
430 |
431 | ### `title`要素を書く
432 |
433 | `title`要素の中身は、ブラウザーに限らず、様々なアプリケーションにより利用されます。
434 |
435 | 悪い例:
436 |
437 |
438 |
439 |
440 |
441 | 良い例:
442 |
443 |
444 |
445 | HTML Best Practices
446 |
447 |
448 |
449 | ### `base`要素を使わない
450 |
451 | 絶対パスや絶対URLの方が開発者とユーザーの双方に安全です。
452 |
453 | 悪い例:
454 |
455 |
456 | ...
457 |
458 |
459 | ...
460 |
461 |
462 | 良い例:
463 |
464 |
465 | ...
466 |
467 | ...
468 |
469 |
470 |
471 | ### マイナーな参照先リソースのMIMEタイプを指定する
472 |
473 | アプリケーションがそのリソースをどう取り扱うべきかのヒントになります。
474 |
475 | 悪い例:
476 |
477 |
478 |
479 |
480 |
481 | 良い例:
482 |
483 |
484 |
485 |
486 |
487 |
488 | ### `favicon.ico`へリンクしない
489 |
490 | ほとんどのブラウザーは`/favicon.ico`を自動的に非同期で取得します。
491 |
492 | 悪い例:
493 |
494 |
495 |
496 | 良い例:
497 |
498 |
499 |
500 |
501 | ### 代替スタイルシートへ`title`属性を追加する
502 |
503 | 人間にわかりやすいラベルにより適切なスタイルシートを選択しやすくなります。
504 |
505 | 悪い例:
506 |
507 |
508 |
509 |
510 | 良い例:
511 |
512 |
513 |
514 |
515 |
516 | ### URLには`link`要素を使う
517 |
518 | `href`属性の値はURLとして解決できます。
519 |
520 | 悪い例:
521 |
522 |
526 |
527 | 良い例:
528 |
529 |
533 |
534 |
535 | ### 文書の文字エンコーディングを指定する
536 |
537 | まだすべてのブラウザーでUTF-8がデフォルトになっていません。
538 |
539 | 悪い例:
540 |
541 |
542 | HTML Best Practices
543 |
544 |
545 | 良い例:
546 |
547 |
548 |
549 | HTML Best Practices
550 |
551 |
552 |
553 | ### 置き換えられるべき文字エンコーディング指定フォーマットを使わない
554 |
555 | HTTPヘッダーはサーバー側で指定されるべきで、簡単にしておきましょう。
556 |
557 | 悪い例:
558 |
559 |
560 |
561 | 良い例:
562 |
563 |
564 |
565 |
566 | ### 最初に文字エンコーディングを指定する
567 |
568 | 仕様では文書の先頭1024バイトまでに文字エンコーディングを指定することを要求しています。
569 |
570 | 悪い例:
571 |
572 |
573 |
574 |
575 | ...
576 |
577 |
578 | 良い例:
579 |
580 |
581 |
582 |
583 | ...
584 |
585 |
586 |
587 | ### UTF-8を使う
588 |
589 | UTF-8ならEmojiを自由に使えます。
590 |
591 | 悪い例:
592 |
593 |
594 |
595 | 良い例:
596 |
597 |
598 |
599 |
600 | ### CSSの`type`属性は省略する
601 |
602 | HTML5では、`style`要素における`type`属性の初期値は`text/css`です。
603 |
604 | 悪い例:
605 |
606 |
609 |
610 | 良い例:
611 |
612 |
615 |
616 |
617 | ### `style`要素の中をコメントアウトしない
618 |
619 | この儀式は古いブラウザーのためです。
620 |
621 | 悪い例:
622 |
623 |
628 |
629 | 良い例:
630 |
631 |
634 |
635 |
636 | ### CSSとJavaScriptのタグを混ぜない
637 |
638 | `script`要素はDOMの構築をブロックすることがあります。
639 |
640 | 悪い例:
641 |
642 |
643 |
644 |
645 |
646 | 良い例:
647 |
648 |
649 |
650 |
651 |
652 | 同じく良い例:
653 |
654 |
655 |
656 |
657 |
658 |
659 | セクション
660 | ----------
661 |
662 | ### `body`要素を書く
663 |
664 | ブラウザーは思っても見ない位置へ`body`要素を補完することがあります。
665 |
666 | 悪い例:
667 |
668 |
669 |
670 | ...
671 |
672 | ...
673 |
674 |
675 | 良い例:
676 |
677 |
678 |
679 | ...
680 |
681 |
682 | ...
683 |
684 |
685 |
686 |
687 | ### `hgroup`要素のことは忘れる
688 |
689 | W3C版仕様では削除されました。
690 |
691 | 悪い例:
692 |
693 |
694 | HTML Best Practices
695 | For writing maintainable and scalable HTML documents.
696 |
697 |
698 | 良い例:
699 |
700 | HTML Best Practices
701 | For writing maintainable and scalable HTML documents.
702 |
703 |
704 | ### `address`要素は連絡先情報にのみ使う
705 |
706 | `address`要素はメールアドレスやSNSアカウント、住所、電話番号など、実際に利用できるあなたとの連絡手段のための要素です。
707 |
708 | 悪い例:
709 |
710 | No rights reserved.
711 |
712 | 良い例:
713 |
714 | Contact: Kyo Nagashima
715 |
716 |
717 | グルーピングコンテンツ
718 | ----------------------
719 |
720 | ### `pre`要素は改行で始めない
721 |
722 | 最初の改行はブラウザーに無視されますが、2番目以降はそのまま表示されます。
723 |
724 | 悪い例:
725 |
726 |
727 | <!DOCTYPE html>
728 |
729 |
730 | 良い例:
731 |
732 | <!DOCTYPE html>
733 |
734 |
735 |
736 | ### `blockquote`要素内でも適切な要素を使う
737 |
738 | `blockquote`要素の中身は引用で、単なる文字の連続ではありません。
739 |
740 | 悪い例:
741 |
742 | For writing maintainable and scalable HTML documents.
743 |
744 | 良い例:
745 |
746 |
747 | For writing maintainable and scalable HTML documents.
748 |
749 |
750 |
751 | ### `blockquote`要素内に帰属情報を含めない
752 |
753 | `blockquote`要素の中身は引用です。
754 |
755 | 悪い例:
756 |
757 |
758 | For writing maintainable and scalable HTML documents.
759 |
760 | — HTML Best Practices
761 |
762 |
763 | 良い例:
764 |
765 |
766 | For writing maintainable and scalable HTML documents.
767 |
768 |
769 | — HTML Best Practices
770 |
771 | 同じく良い例(WHATWG推奨):
772 |
773 |
774 |
775 | For writing maintainable and scalable HTML documents.
776 |
777 |
778 | — HTML Best Practices
779 |
780 |
781 | 同じく良い例(W3C推奨):
782 |
783 |
784 | For writing maintainable and scalable HTML documents.
785 |
786 |
787 |
788 |
789 |
790 | ### リスト項目は1行に1つずつ書く
791 |
792 | 長ーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーーい行はとっっっっっっっっっっっっっっっっっっっっっっっっっっっても読みづらいです。
793 |
794 | 悪い例:
795 |
796 |
797 | General The root Element Sections ...
798 |
799 |
800 | 良い例:
801 |
802 |
803 | General
804 | The root Element
805 | Sections
806 | ...
807 |
808 |
809 |
810 | ### `ol`要素では`type`属性を使う
811 |
812 | リスト・マーカーは周辺から参照されることもあります。`type`属性を使ってリスト・マーカーを変更すれば、安全に参照できるでしょう。
813 |
814 | 悪い例:
815 |
816 |
817 |
822 |
823 |
824 |
825 | General
826 | The root Element
827 | Sections
828 | ...
829 |
830 |
831 |
832 | 良い例:
833 |
834 |
835 |
836 | General
837 | The root Element
838 | Sections
839 | ...
840 |
841 |
842 |
843 |
844 | ### `dl`を会話のために使わない
845 |
846 | HTML5では`dl`要素は関連付けリストに限定されています。
847 |
848 | 悪い例:
849 |
850 |
851 | Costello
852 | Look, you gotta first baseman?
853 | Abbott
854 | Certainly.
855 | Costello
856 | Who’s playing first?
857 | Abbott
858 | That’s right.
859 | Costello becomes exasperated.
860 | Costello
861 | When you pay off the first baseman every month, who gets the money?
862 | Abbott
863 | Every dollar of it.
864 |
865 |
866 | 良い例:
867 |
868 | Costello: Look, you gotta first baseman?
869 | Abbott: Certainly.
870 | Costello: Who’s playing first?
871 | Abbott: That’s right.
872 | Costello becomes exasperated.
873 | Costello: When you pay off the first baseman every month, who gets the money?
874 | Abbott: Every dollar of it.
875 |
876 |
877 | ### `figcaption`要素は`figure`要素の最初か最後に置く
878 |
879 | 仕様(WHATWG版)では`figcaption`要素を`figure`要素の中ほどに置くことは許可されていません。
880 |
881 | 悪い例:
882 |
883 |
884 |
885 | “HTML Best Practices” Cover Art
886 |
887 |
888 |
889 | 良い例:
890 |
891 |
892 |
893 |
894 | “HTML Best Practices” Cover Art
895 |
896 |
897 |
898 | ### `main`要素を使う
899 |
900 | `main`要素はコンテンツをまとめるために使えます。
901 |
902 | 悪い例:
903 |
904 |
905 | ...
906 |
907 |
908 | 良い例:
909 |
910 |
911 | ...
912 |
913 |
914 |
915 | ### できる限り`div`要素は避ける
916 |
917 | `div`要素は最後の手段です。
918 |
919 | 悪い例:
920 |
921 |
922 | ...
923 |
924 |
925 | 良い例:
926 |
927 |
930 |
931 |
932 | テキストレベルセマンティックス
933 | ------------------------------
934 |
935 | ### グループ化できるリンクは分割しない
936 |
937 | `a`要素はほとんどの要素(フォームコントロールのようなインタラクティブ要素や`a`要素自身以外)を括ることができます。
938 |
939 | 悪い例:
940 |
941 |
942 |
943 | A community maintaining and evolving HTML since 2004.
944 |
945 | 良い例:
946 |
947 |
948 | WHATWG
949 |
950 | A community maintaining and evolving HTML since 2004.
951 |
952 |
953 |
954 | ### リソースをダウンロードさせる場合は`download`属性を使う
955 |
956 | こうすることでダウンロードするリンク先のリソースを確実にローカルに保存させることができます。
957 |
958 | 悪い例:
959 |
960 | offline version
961 |
962 | 良い例:
963 |
964 | offline version
965 |
966 |
967 | ### `rel`や`hreflang`、`type`属性を必要ならば使う
968 |
969 | これらのヒントは、アプリケーションがリンク先のリソースをどう扱えば良いのかの助けになります。
970 |
971 | 悪い例:
972 |
973 | Japanese PDF version
974 |
975 | 良い例:
976 |
977 | Japanese PDF version
978 |
979 |
980 | ### リンク文字列は明確にする
981 |
982 | リンク文字列はリンク先のリソースのラベルであるべきです。
983 |
984 | 悪い例:
985 |
986 | Click here to view PDF version.
987 |
988 | 良い例:
989 |
990 | PDF version is also available.
991 |
992 |
993 | ### `em`要素を警告や注意に使わない
994 |
995 | それらは深刻なものです。ですから`strong`要素の方がより相応しいはずです。
996 |
997 | 悪い例:
998 |
999 | Caution!
1000 |
1001 | 良い例:
1002 |
1003 | Caution!
1004 |
1005 |
1006 | ### できる限り`s`や`i`、`b`、`u`要素を避ける
1007 |
1008 | これらの要素のセマンティクスは人類には難しすぎます。
1009 |
1010 | 悪い例:
1011 |
1012 |
1013 |
1014 | 良い例:
1015 |
1016 |
1017 |
1018 |
1019 | ### `q`要素内へ引用符は置かない
1020 |
1021 | 引用符はブラウザーが提供します。
1022 |
1023 | 悪い例:
1024 |
1025 | “For writing maintainable and scalable HTML documents”
1026 |
1027 | 良い例:
1028 |
1029 | For writing maintainable and scalable HTML documents
1030 |
1031 | 同じく良い例:
1032 |
1033 | “For writing maintainable and scalable HTML documents”
1034 |
1035 |
1036 | ### `abbr`要素へ`title`属性を追加する
1037 |
1038 | 他に完全表記を提示する方法がありません。
1039 |
1040 | 悪い例:
1041 |
1042 | HBP
1043 |
1044 | 良い例:
1045 |
1046 | HBP
1047 |
1048 |
1049 | ### `ruby`要素は冗長にマークアップする
1050 |
1051 | `ruby`要素のサポートはまだモダンブラウザー間でも完了していません。
1052 |
1053 | 悪い例:
1054 |
1055 | HTMLえいちてぃーえむえる
1056 |
1057 | 良い例:
1058 |
1059 | HTML ( えいちてぃーえむえる )
1060 |
1061 |
1062 | ### 機械的に解釈可能でない`time`要素では`datetime`属性を追加する
1063 |
1064 | `datetime`属性を使わない場合、`time`要素の中身は限定されます。
1065 |
1066 | 悪い例:
1067 |
1068 | Dec 19, 2014
1069 |
1070 | 良い例:
1071 |
1072 | Dec 19, 2014
1073 |
1074 |
1075 | ### コードの言語は`class`属性で`language-`で始めることで指定する
1076 |
1077 | これは正式な方法ではありませんが、仕様では言及されています。
1078 |
1079 | 悪い例:
1080 |
1081 | <!DOCTYPE html>
1082 |
1083 | 良い例:
1084 |
1085 | <!DOCTYPE html>
1086 |
1087 |
1088 | ### できる限り`kbd`要素はシンプルにする
1089 |
1090 | 入れ子にした`kbd`要素は人類には難しすぎます。
1091 |
1092 | 悪い例:
1093 |
1094 | Ctrl +F5
1095 |
1096 | 良い例:
1097 |
1098 | Ctrl+F5
1099 |
1100 |
1101 | ### できる限り`span`要素は使わない
1102 |
1103 | `span`要素は最後の手段です。
1104 |
1105 | 悪い例:
1106 |
1107 | HTML Best Practices
1108 |
1109 | 良い例:
1110 |
1111 | HTML Best Practices
1112 |
1113 |
1114 | ### `br`要素の後ろでは改行する
1115 |
1116 | `br`要素が使われる場所には、間違いなく改行が必要です。
1117 |
1118 | 悪い例:
1119 |
1120 | HTML Best Practices
1121 |
1122 | 良い例:
1123 |
1124 | HTML
1125 | Best
1126 | Practices
1127 |
1128 |
1129 | ### 見た目だけのために`br`要素を使わない
1130 |
1131 | `br`要素は改行のためにあるのではなく、コンテンツに必要な改行のためにあります。
1132 |
1133 | 悪い例:
1134 |
1135 | Rule name:
1136 | Rule description:
1137 |
1138 |
1139 | 良い例:
1140 |
1141 | Rule name:
1142 | Rule description:
1143 |
1144 |
1145 |
1146 | 編集
1147 | ----
1148 |
1149 | ### `ins`や`del`要素は他の要素をまたがせない
1150 |
1151 | 要素は他の要素をまたぐことはできません。
1152 |
1153 | 悪い例:
1154 |
1155 | For writing maintainable and scalable HTML documents. And for mental stability.
1156 |
1157 | Don’t trust!
1158 |
1159 | 良い例:
1160 |
1161 | For writing maintainable and scalable HTML documents. And for mental stability.
1162 |
1163 | Don’t trust!
1164 |
1165 |
1166 | エンベディッドコンテンツ
1167 | ------------------------
1168 |
1169 | ### `picture`要素ではフォールバックのための`img`要素を提供する
1170 |
1171 | `picture`要素のサポートはまだよくありません。
1172 |
1173 | 悪い例:
1174 |
1175 |
1176 |
1177 |
1178 |
1179 |
1180 |
1181 |
1182 | 良い例:
1183 |
1184 |
1185 |
1186 |
1187 |
1188 |
1189 |
1190 |
1191 |
1192 | ### 必要な時は`img`要素へ`alt`属性を追加する
1193 |
1194 | `alt`属性は、画像を表示できなかったり、画像の読み込みを無効にしている環境へ助けになります。
1195 |
1196 | 悪い例:
1197 |
1198 |
1199 |
1200 | 良い例:
1201 |
1202 |
1203 |
1204 |
1205 | ### 可能ならば`alt`属性は空にする
1206 |
1207 | 画像が補助的なものならば、きっと周囲に同等のコンテンツが存在するはずです。
1208 |
1209 | 悪い例:
1210 |
1211 | Help
1212 |
1213 | 良い例:
1214 |
1215 | Help
1216 |
1217 |
1218 | ### 可能ならば`alt`属性は省略する
1219 |
1220 | たまにどのような文字列が適切な`alt`属性の値かわからないこともあります。
1221 |
1222 | 悪い例:
1223 |
1224 |
1225 |
1226 | 良い例:
1227 |
1228 |
1229 | (If you cannot see the image, you can use an audio test instead.)
1230 |
1231 |
1232 | ### `iframe`要素の中は空にする
1233 |
1234 | その内容にはいくつかの制限があります。空にすれば安全です。
1235 |
1236 | 悪い例:
1237 |
1238 |
1241 |
1242 | 良い例:
1243 |
1244 |
1245 |
1246 |
1247 | ### `map`要素の中はマークアップする
1248 |
1249 | その中身はスクリーン・リーダーへ提供されます。
1250 |
1251 | 悪い例:
1252 |
1253 |
1254 | General
1255 | |
1256 | The root element
1257 | |
1258 | Sections
1259 |
1260 |
1261 |
1262 | 良い例:
1263 |
1264 |
1265 |
1266 | General
1267 | |
1268 | The root element
1269 | |
1270 | Sections
1271 |
1272 |
1273 |
1274 |
1275 |
1276 | ### `audio`や`video`要素にフォールバックのためのコンテンツを提供する
1277 |
1278 | HTML5で新しく作られた要素にはフォールバックのためのコンテンツが必要です。
1279 |
1280 | 悪い例:
1281 |
1282 |
1283 |
1284 |
1285 | ...
1286 |
1287 |
1288 | 良い例:
1289 |
1290 |
1291 |
1292 |
1293 | ...
1294 |
1295 |
1296 |
1297 |
1298 | テーブルデータ
1299 | --------------
1300 |
1301 | ### 1行に1つのセルを書く
1302 |
1303 | 長い行は把握しづらいです。
1304 |
1305 | 悪い例:
1306 |
1307 |
1308 | General The root Element Sections
1309 |
1310 |
1311 | 良い例:
1312 |
1313 |
1314 | General
1315 | The root Element
1316 | Sections
1317 |
1318 |
1319 |
1320 | ### 見出しセルには`th`要素を使う
1321 |
1322 | 避ける理由はないでしょう。
1323 |
1324 | 悪い例:
1325 |
1326 |
1327 |
1328 |
1329 | Element
1330 | Empty
1331 | Tag omission
1332 |
1333 |
1334 |
1335 |
1336 | pre
1337 | No
1338 | Neither tag is omissible
1339 |
1340 |
1341 | img
1342 | Yes
1343 | No end tag
1344 |
1345 |
1346 |
1347 |
1348 | 良い例:
1349 |
1350 |
1351 |
1352 |
1353 | Element
1354 | Empty
1355 | Tag omission
1356 |
1357 |
1358 |
1359 |
1360 | pre
1361 | No
1362 | Neither tag is omissible
1363 |
1364 |
1365 | img
1366 | Yes
1367 | No end tag
1368 |
1369 |
1370 |
1371 |
1372 |
1373 | フォーム
1374 | --------
1375 |
1376 | ### フォームコントロールは`label`要素で括る
1377 |
1378 | `label`要素はフォーム要素へフォーカスを当てるのに役立ちます。
1379 |
1380 | 悪い例:
1381 |
1382 | Query:
1383 |
1384 | 良い例:
1385 |
1386 | Query:
1387 |
1388 |
1389 | ### 可能ならば`for`属性は省略する
1390 |
1391 | `label`要素はいくつかのフォーム要素を含められます。
1392 |
1393 | 悪い例:
1394 |
1395 | Query:
1396 |
1397 | 良い例:
1398 |
1399 | Query:
1400 |
1401 |
1402 | ### `input`要素では適切な`type`属性を使う
1403 |
1404 | 適切な`type`属性により、ブラウザーは`input`要素へちょっとした機能を与えてくれます。
1405 |
1406 | 悪い例:
1407 |
1408 | Search keyword:
1409 |
1410 | 良い例:
1411 |
1412 | Search keyword:
1413 |
1414 |
1415 | ### `input type="submit"`には`value`属性を追加する
1416 |
1417 | 送信ボタンは、そのデフォルトのラベルがブラウザーや言語設定によって変わってしまいます。
1418 |
1419 | 悪い例:
1420 |
1421 |
1422 |
1423 | 良い例:
1424 |
1425 |
1426 |
1427 |
1428 | ### `pattern`属性を持つ`input`要素には`title`属性を追加する
1429 |
1430 | もし入力したテキストが`pattern`属性にマッチしない場合、`title`属性の値がヒントとして表示されます。
1431 |
1432 | 悪い例:
1433 |
1434 |
1435 |
1436 | 良い例:
1437 |
1438 |
1439 |
1440 |
1441 | ### `placeholder`属性をラベル付けに使わない
1442 |
1443 | `label`要素がラベルのためにあり、`placeholder`属性は短いヒントのためにあります。
1444 |
1445 | 悪い例:
1446 |
1447 |
1448 |
1449 | 良い例:
1450 |
1451 | Email:
1452 |
1453 |
1454 | ### `option`要素は1行に1つ書く
1455 |
1456 | 長い行は把握しづらいです。
1457 |
1458 | 悪い例:
1459 |
1460 |
1461 |
1462 |
1463 |
1464 | 良い例:
1465 |
1466 |
1467 |
1468 |
1469 |
1470 |
1471 |
1472 |
1473 | ### `progress`要素には`max`属性を追加する
1474 |
1475 | `max`属性があると、`value`属性を簡単な形式で書くことができます。
1476 |
1477 | 悪い例:
1478 |
1479 | 50%
1480 |
1481 | 良い例:
1482 |
1483 | 50%
1484 |
1485 |
1486 | ### `meter`要素では`min`及び`max`属性を追加する
1487 |
1488 | `min`と`max`属性があると、`value`属性を簡単な形式で書くことができます。
1489 |
1490 | 悪い例:
1491 |
1492 | 512GB used (1024GB total)
1493 |
1494 | 良い例:
1495 |
1496 | 512GB used (1024GB total)
1497 |
1498 |
1499 | ### `legend`要素は`fieldset`要素の最初に置く
1500 |
1501 | 仕様がそう要求しています。
1502 |
1503 | 悪い例:
1504 |
1505 |
1506 | Is this section is useful?:
1507 | ...
1508 | About "General"
1509 |
1510 |
1511 | 良い例:
1512 |
1513 |
1514 | About "General"
1515 | Is this section is useful?:
1516 | ...
1517 |
1518 |
1519 |
1520 | スクリプティング
1521 | ----------------
1522 |
1523 | ### JavaScriptでは`type`属性を省略する
1524 |
1525 | HTML5では、`script`要素における`type`属性の初期値は`text/javascript`です。
1526 |
1527 | 悪い例:
1528 |
1529 |
1532 |
1533 | 良い例:
1534 |
1535 |
1538 |
1539 |
1540 | ### `script`要素の中をコメントアウトしない
1541 |
1542 | この儀式は古いブラウザーのためです。
1543 |
1544 | 悪い例:
1545 |
1546 |
1551 |
1552 | 同じく悪い例:
1553 |
1554 |
1559 |
1560 | 良い例:
1561 |
1562 |
1565 |
1566 |
1567 | ### `script`要素を動的に生成するテクニックを使わない
1568 |
1569 | 明快さとパフォーマンスの両面で`async`属性が最良です。
1570 |
1571 | 悪い例:
1572 |
1573 |
1579 |
1580 | 良い例:
1581 |
1582 |
1583 |
1584 |
1585 | その他
1586 | ------
1587 |
1588 | ### 一貫した量でインデントする
1589 |
1590 | インデントは読みやすさにおいて重要です。
1591 |
1592 | 悪い例:
1593 |
1594 |
1595 |
1596 | ...
1597 |
1598 |
1599 | ...
1600 |
1601 |
1602 |
1603 | 良い例:
1604 |
1605 |
1606 |
1607 | ...
1608 |
1609 |
1610 | ...
1611 |
1612 |
1613 |
1614 |
1615 | ### 内部リンクには絶対パスを使う
1616 |
1617 | 絶対パスはインターネット回線のないローカルの環境でもうまく動きます。
1618 |
1619 | 悪い例:
1620 |
1621 |
1622 | ...
1623 | You can find more at contact page .
1624 |
1625 | 良い例:
1626 |
1627 |
1628 | ...
1629 | You can find more at contact page .
1630 |
1631 |
1632 | 投稿者
1633 | ------
1634 |
1635 | - [@hail2u]
1636 | - [@momdo]
1637 | - [@techhtml]
1638 |
1639 |
1640 | ライセンス
1641 | ----------
1642 |
1643 | [CC0]
1644 |
1645 |
1646 | [@hail2u]: https://github.com/hail2u
1647 | [@momdo]: https://github.com/momdo
1648 | [@techhtml]: https://github.com/techhtml
1649 | [CC0]: http://creativecommons.org/publicdomain/zero/1.0/
1650 |
--------------------------------------------------------------------------------