Computer >> 컴퓨터 >  >> 프로그램 작성 >> CSS

CSS를 사용하여 선택기에서 텍스트의 첫 번째 줄에 특수 스타일을 추가하는 데 사용되는 요소

<시간/>

:첫줄 사용 문서에서 요소의 첫 번째 줄에 특수 효과를 추가하는 요소입니다.

예시

다음 코드를 실행하여 텍스트의 첫 번째 줄에 특수 스타일을 추가할 수 있습니다.

<html>
   <head>
      <style>
         p:first-line {
            text-decoration: underline;
         }
         p.noline:first-line {
            text-decoration: none;
         }
      </style>
   </head>
   <body>
      <p class = "noline"> This line would not have any underline because this belongs to nline class.</p>
      <p>The first line of this paragraph will be underlined as defined in the CSS rule above. Rest of the
      lines in this paragraph will remain normal. This example shows how to use :first-line pseduo element
      to give effect to the first line of any HTML element.</p>
   </body>
</html>