HTML5 이후의 a태그

인라인요소 안에 블럭요소를 넣으면 웹접근성에 위배된다.

HTML5 이전에는 a태그는 오직 인라인 요소만 포함할 수 있었지만 HTML5 이후로는 a 태그는 transparent인 태그라 인라인 요소와 블록 요소 둘 다 포함할 수 있다.

Although previous versions of HTML restricted the a element to only containing phrasing content (essentially, what was in previous versions referred to as “inline” content), the a element is now transparent; that is, an instance of the a element is now allowed to also contain flow content (essentially, what was in previous versions referred to as “block” content)—if the parent element of that instance of the a element is an element that is allowed to contain flow content.

특정 요소 foo가 transparent면 다음과 같은 속성을 가진다.

  • foo 요소가 콘텐츠 모델이 flow 요소를 포함하도록 허용 된 상위 요소 baz 의 자식인 경우 foo 요소의 콘텐츠도 flow 요소 를 포함할 수 있습니다 .

  • foo 요소가 콘텐츠 모델이 phrasing 요소를 포함하도록 허용 된 상위 요소 baz 의 자식인 경우 foo 요소의 콘텐츠 도 phrasing 요소를 포함할 수 있습니다 .

즉 부모요소의 콘텐츠 모델을 따르게 된다.

콘텐츠 모델에 대한 설명은 여기서 볼 수 있다.

댓글