Home >Web Front-end >CSS Tutorial >Why Isn't My CSS `:first-letter` Selector Working on a Span Element?
An attempt to style the first letter of a title section generated using Microsoft Word's HTML output has failed using the :first-letter selector. The HTML contains a span element with various inline styles.
The issue arises because :first-letter only works on block-level elements, as defined in the MDN documentation. In this case, the span element is an inline element.
To resolve the issue, there are two options:
p::first-letter { font-size: 500px; }
p b span::first-letter { font-size: 500px !important; } span { display: inline-block; }
The above is the detailed content of Why Isn't My CSS `:first-letter` Selector Working on a Span Element?. For more information, please follow other related articles on the PHP Chinese website!