관리 메뉴

틈틈히 메모중

[오늘의 HTML] anchor 태그에 block 요소를 넣어도 되는가 본문

[오늘의 공부]/html&CSS

[오늘의 HTML] anchor 태그에 block 요소를 넣어도 되는가

개피곤씨 2023. 2. 4. 23:15

된다고 합니다.
ㅎㅎ
 
HTML을 배울때 인라인요소 안에 블럭요소를 넣으면 안된다고 배웠다. 
리액트를 한다면 이동할때 라우터를 쓰니까 괜찮다지만 바닐라 자바스크립트를 쓸경우 
a태그를 활용해서 경로를 작성하게된다. 
 
그렇게 작업하다보면 
당연히 span 같은 인라인요소에는 블럭요소를 넣지 않겠지만,
a태그에는 부득이 블럭요소가 왕왕 들어갈때가 많았다. (마음에 돌얹힘)
 

Changes in HTML5 

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.

출처 : https://w3c.github.io/html-reference/a.html#a-changes

 

 
위 내용은 a 태그가 예전에는 인라인만 포함하도록 했지만,
NOW(html5)엔 flow content를 포함하는 것을 허용했다. (이전에 블록이라고 언급되었던 것들말이야...그거다 허용이야!)
- 제 해석에 오류가 있다면 알려주세오... 
 
이젠 편히 넣겠어요:)