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

CSS를 사용한 텍스트 들여쓰기

<시간/>

CSS text-indent 속성은 요소의 첫 번째 줄 들여쓰기를 설정하는 데 도움이 됩니다.

구문

CSS text-indent 속성의 구문은 다음과 같습니다 -

Selector {
   text-indent: /*value*/
}

예시

다음 예는 CSS 텍스트 들여쓰기 속성을 보여줍니다.

<!DOCTYPE html>
<html>
<head>
<style>
div {
   display: flex;
   float: left;
   margin: auto;
   padding: 10px;
}
article {
   text-indent: 25%;
   background-color: darkseagreen;
   padding: 15px;
   font-size: 1.3em;
}
h3 {
   text-indent: -0.8em;
}
</style>
</head>
<body>
<div>
<h3>Doing it our way. Nothing gonna turn us back now.</h3>
<article>
This is demo paragraph. This is demo paragraph. This is demo paragraph. 
This is demo paragraph. This is demo paragraph. This is demo paragraph. 
This is demo paragraph. This is demo paragraph. This is demo paragraph. 
This is demo paragraph. This is demo paragraph. This is demo paragraph. </article>
</div>
</body>
</html>

출력

이것은 다음 출력을 제공합니다 -

CSS를 사용한 텍스트 들여쓰기

예시

<!DOCTYPE html>
<html>
<head>
<style>
ul {
   list-style: none;
   display: flex;
   float: left;
   text-indent: 23px;
   background-image: url("https://www.tutorialspoint.com/angular4/images/angular-4.jpg");
   font-size: 1.5em;
}
li {
   border: thin solid;
}
</style>
</head>
<body>
<ul>
<li>This is demo text. This is demo text.</li>
<li>Angular 4 is a JavaScript framework for building web applications and apps in JavaScript, html, and TypeScript, which is a superset of JavaScript. </li>
<li>Angular provides built-in features for animation, http service, and materials which in turn has features such as auto-complete, navigation, toolbar, menus, etc</li>
<li>This is demo text. This is demo text.</li>
</ul>
</body>
</html>

출력

이것은 다음 출력을 제공합니다 -

CSS를 사용한 텍스트 들여쓰기