initial-letter

CSS initial-letter Property

The initial-letter property specifies the first letter and the number of lines it occupies.

This property appears in newspapers where the first letter is larger than the rest of the content.

This property has three values: normal, <number>, <integer>.

Negative values are not allowed.

Only Safari supports this property.

类目类目
Initial Valuenormal
Applies to::first-letter pseudo-elements and inline-level first child of a block container.
InheritedNo.
AnimatableNo.
VersionCSS3
DOM SyntaxObject.style.initialLetter = “<number>”;

Syntax

Syntax

initial-letter: normal | <number> | <integer>;

Example of the initial-letter property:

<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      body {
        display: flex;
        align-items: center;
        justify-content: center;
        font-family: 'Slabo 27px';
        font-size: 1.5em;
        line-height: 1.5;
        padding: 40px 0;
      }
      article {
        width: 80%;
      }
      .example::first-letter {
        -webkit-initial-letter: 2;
        initial-letter: 1;
        color: #8ebf42;
        font-weight: bold;
        margin-right: .60em;
      }
    </style>
  </head>
  <body>
    <article class="example">
      Lorem Ipsum is dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged.
    </article>
  </body>
</html>

Result

Values

Values

ValueDescription
normalNo initial-letter effect. This is the default value of this property.
<number>Specifies the size of the initial letter, how many lines it occupies. Negative values are not allowed.
<integer>Specifies how many lines the initial letter should sink.
initialMakes the property use its default value.
inheritInherits the property from its parents element.


请遵守《互联网环境法规》文明发言,欢迎讨论问题
扫码反馈

扫一扫,反馈当前页面

咨询反馈
扫码关注
返回顶部