Content Property

The content attribute produces dynamic content. It can be applied with any pseudo-element ::after and ::before. These CSS properties are entirely supported inside every browser and applied to include the content over the web page.

It can replace an item with any produces value.

Syntax:

 Property Values

This property of CSS has a lot of values which are specified as follows:

ValuesDescription
normalThis value is used as a default value.
noneIt can’t set any content.
counterThis value can be used to set any content as a counter. Generally, it is a number. This value can be shown with counters() or counter() function.
stringThis property value sets the string value. This value must always be wrapped inside quotation masks. These values produce the string before or after any HTML element.
attrThis property value includes any specified element’s value before or after any element. The empty string can be added, if the selectors do not contain any particular attribute.
open-quoteThis value includes any opening quotation mark. It can be used to set the text to be the opening quote.
close-quoteThis value includes any closing quotation mark. It can be used to set the text to be the closing quote.
no-close-quoteWhen a closing quote is specified, it is applied to eliminate the specified closing quote against the text.
no-open-quoteWhen an opening quote is specified, it is applied to eliminate the specified opening quote against the text.
urlThis property value sets the text into the media, which can be audio, video, image, and others.
initialThe initial value sets the Content property to the default value.
inheritThis value acquires the property against its parent item.

Let’s take a few examples of the above-discussed values as below:

Example: none and normal value

In the following example, we use pseudo-element ::before to add the content “Welcome” before a paragraph element. The content can’t be inserted into those elements of a paragraph where we used none and normal values.

Output:

CSS Content Property

Example: url and string value
In the following example, the content “Hello all!! Welcome” will be inserted with the use of the content attribute and pseudo-element ::before.

Output:

CSS Content Property

Example:  close-quote and open-quote value

The close-quote can only be applied with the open-quote as follows:

Output:

CSS Content Property

Example: no-close-quote and no-open-quote value

In the following example, we use the close-quote and the open-quote over the paragraph items, and we use the .para class over the paragraph on the no-close-quote and the no-open-quote.

Output:

CSS Content Property

Example: attr() value

The function attr() allows us to add any particular element’s value. If any corresponding item does not include any attribute, any empty string can be returned.

In the following illustration, we are applying the function attr(), the link shown over the screen.

Output:

CSS Content Property

Pin It on Pinterest

Share This