- 웹/HTML

[HTML] html 태그 안에서 꺽쇠<> 괄호 사용하기 (&lt; &gt;)

codingEasy 2021. 1. 3. 23:21

 &lt; 와 &gt;

 

HTML 작성 시, 꺽쇠 괄호 <> 를 출력하려는데, 간혹 원하는 결과값이 나오지 않는 경우가 있다.

그건 HTML에서는 꺽쇠 괄호 <>는 HTML 태그의 꺽쇠 괄호로 인지하는 경우가 있기 때문이다.

 

 

그래서 HTML태그 안에서 꺽쇠 괄호 <>를 사용하고 싶을때에는 &lt; 와 &gt; 로 사용한다.

&lt; 는 less than (<) 의 줄임말이고 &gt; 는 greater than (>) 의 약자라고 한다.

 

 

 사용 예시

<h1>오늘 <몽실언니> 책을 읽었어.</h1>

<h1>오늘 &lt;몽실언니&gt; 책을 읽었어.<h1>

Eclipse의 HTML 파일에서 시험을 해보았다.

근데, 둘 다 내가 원하는 값으로 출력되기는 했다.. =_=

출력되기는 하는데 경고문이 뜬다.

마우스를 위에 갖다 대면 Unknown tag 라고 뜬다.

 

 

그래도 HTML태그로 인식하여 원하는 값이 나오지 않을 경우가 있을 수있으니

왠만하면 저 &lt; &gt; 로 사용하는 것이 나을 것 같다.

 

 

 

 

더 많은 HTML Character Entities 보기 ↓

더보기

Some Useful HTML Character Entities

ResultDescriptionEntity NameEntity Number

Result Description Entity Name Entity Number
  non-breaking space &nbsp; &#160;
< less than &lt; &#60;
> greater than &gt; &#62;
& ampersand &amp; &#38;
" double quotation mark &quot; &#34;
' single quotation mark (apostrophe) &apos; &#39;
¢ cent &cent; &#162;
£ pound &pound; &#163;
¥ yen &yen; &#165;
euro &euro; &#8364;
© copyright &copy; &#169;
® registered trademark &reg; &#174;

Note: Entity names are case sensitive.

 

 

참고사이트 : www.w3schools.com/html/html_entities.asp