html text property,CSS: text-indent property

Example

We will discuss the text-indent property below, exploring examples of how to use this property in CSS.

Using Fixed Value

Let's look at a CSS text-indent example where we have provided the text-indent as a fixed value expressed in pixels.

The CSS would look like this:

div { background: lightyellow; padding: 10px; }

p { text-indent: 25px; }

The HTML would look like this:

TechOnTheNet.com has been providing helpful references, how-to's and FAQs since 2003.

CheckYourMath.com has answers to your every day Math questions.

The result would look like this:

9c09f3dfc46bc46c3af6c1ebd362f0cb.png

In this CSS text-indent example, we have set the text-indent to 25px for the

tag. This will indent the first line of text for each paragraph by 25px.

We can also express the text-indent as a fixed value in em's. So using the same HTML, we could modify our CSS as follows:

div { background: lightyellow; padding: 10px; }

p { text-indent: 5em; }

The result would now look like this:

6f221302cb7b34c311acdb36fe6b1dd0.png

In this CSS text-indent example, we have set the

tag to a text-indent of 5em, which appears as a slightly larger indent than 25px. The text-indent applies to the first line of text for each of the paragraphs.

Using Percentage

Let's look at a CSS text-indent example where we have provided the text-indent as a percentage.

The CSS would look like this:

div { background: lightyellow; padding: 10px; }

p { text-indent: 5%; }

The HTML would look like this:

TechOnTheNet.com has been providing helpful references, how-to's and FAQs since 2003.

CheckYourMath.com has answers to your every day Math questions.

The result would look like this:

5d0ef4826980b783bd919c7525e1ba75.png

In this CSS text-indent example, we have set the text-indent of the

tag to 5%, which means that the text-indent would be 5% of the width of the container for the first text line of each of the paragraphs.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值