CSS content propertyThis CSS property generates dynamic content. It can be used with the pseudo-elements ::before and ::after. This CSS property is fully supported in all browsers and used to insert the generated content on a web page. It replaces the element with the generated value. SyntaxProperty ValuesThis CSS property has numerous values that are defined in the following table:
Let's see some of the illustrations of this CSS property. Example - Using normal and none value In this example, we are using ::before pseudo-element for inserting the text "Welcome " before the paragraph elements. The text will not be added to those paragraph elements on which we applied the values normal and none. Test it NowOutput Example - Using string and url value In this example the text "Hello World. Welcome " is added by using the content property and ::before pseudo-element. Test it NowOutput Example - Using open-quote and close-quote value We cannot apply close-quote without open-quote. Test it NowOutput Example - Using no-open-quote and no-close-quote value In this example, we have applied the open-quote and close-quote on paragraph elements, and on paragraph with class .para we applied the no-open-quote and no-close-quote. Test it NowOutput Example - Using attr() The attr() function allows us to insert the value of a particular attribute. If the corresponding element does not have an attribute, then an empty string will be returned. In this example, the link displayed on the screen is by using the attr() function. Test it NowOutput Next TopicCSS word-spacing |