CSS Properties: How to removes the opening quote from the content, if specified?
Solution:
HTML Code:
<!DOCTYPE html><!-- Specifies the document type and version of HTML -->
<html>
<head>
<title>How to removes the opening quote from the content, if specified</title><!-- Sets the title of the HTML document -->
<style type="text/css"> /* Begins a CSS style block */
p:before {
content: open-quote; /* Inserts an opening quote before the content of all <p> elements */
}
p:after {
content: close-quote; /* Inserts a closing quote after the content of all <p> elements */
}
p.w3r:before {
content: no-open-quote; /* Removes the opening quote from the content of <p> elements with class "w3r" */
}
p.w3r:after {
content: no-close-quote; /* Removes the closing quote from the content of <p> elements with class "w3r" */
}
</style><!-- Ends the CSS style block -->
</head>
<body>
<p>w3resource - HTML5</p><!-- Inserts a paragraph element with the specified content -->
<p class="w3r">w3resource - CSS3</p><!-- Inserts a paragraph element with the specified content and class "w3r" -->
<p><strong>Note:</strong>You cannot have "close-quote" without "open-quote".</p><!-- Inserts a paragraph element with a note -->
</body>
</html>
Explanation:
- This HTML document demonstrates how to use the content property in CSS to insert and remove opening and closing quotes before and after the content of selected elements.
- The CSS rule p:before selects the pseudo-element ::before of all <p> elements and inserts an opening quote using content: open-quote;.
- The CSS rule p:after selects the pseudo-element ::after of all <p> elements and inserts a closing quote using content: close-quote;.
- The CSS rule p.w3r:before targets <p> elements with the class "w3r" and removes the opening quote from their content using content: no-open-quote;.
- The CSS rule p.w3r:after targets <p> elements with the class "w3r" and removes the closing quote from their content using content: no-close-quote;.
Live Demo :
See the Pen content-no-open-quote-answer by w3resource (@w3resource) on CodePen.
See the solution in the browser
Supported browser
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics