HTML/웹호환ㆍ크로스브라우징

조건부 주석 / html5shiv

은선은 2022. 7. 13. 09:55

조건부 주석

 

<!--[if condition]> 
	코드
<![endif]-->

 

  • ! : 아니다(not) - 예) [if !ie] ie가 아니라면
  • lt : 작다(less than) - 예) [if lt ie 9] ie9 보다 작다면
  • lte : 작거나 같다(less than equal) - 예)  [if lte ie 8] ie8 보다 작거나 같다면
  • gt : 크다(greater than) - 예) [if gt ie 6] ie6 보다 크다면
  • gte : 크거나 같다(greater than equal) - 예) [if gte ie 7] ie7 보다 크거나 같다
  • () : 우선처리
  • & : 그리고(and) - 예) [if (gte ie 7)&(lt ie 9)] ie7 이상이고 ie9 미만이라면
  • | : 또는(or) - 예) [if (ie 7)|(ie 8)] ie7 이거나 ie8 이라면

 

<!--[if !IE]><!-->
	<script>
  		if (/*@cc_on!@*/ false) {
    		document.documentElement.className += "ie10";
  		}
	</script>
<!--<![endif]-->

 


html5shiv

HTML5 Shiv는 레거시 Internet Explorer에서 HTML5 섹션 요소를 사용할 수 있게 하고 Internet Explorer 6-9, Safari 4.x(및 iPhone 3.x) 및 Firefox 3.x에 대한 기본 HTML5 스타일을 제공합니다.

 

<!--[if lt IE 9]>
	<script src="https://cdn.jsdelivr.net/npm/html5shiv@3.7.3/dist/html5shiv.min.js"></script>
	<script type="text/javascript">
		alert("해당 브라우저는 지원하지 않습니다.\n(지원 브라우저: Chrome, Opera, Firefox, Safari, Edge 그 외 Chrome 기반 브라우저)");
	</script>
<![endif]-->

 

 


 

출처 

https://webdir.tistory.com/451

https://github.com/aFarkas/html5shiv