This is the easy way to add the copy button on the page.
Note: Prefer this option, if you have multiple pages, and want to add the copy button to all those elements. E.g. You have a code block on multiple pages then you can use this easy method.
In this documentation, we are going to see how to add the copy button with the HTML Tag Selector.
Before adding the copy button with the CSS class selector, we need the sample demo page.
We have created the demo page with dummy content.
See the demo content and the dummy page
Great, After creating the demo page, or, checking how the demo page content looks like, let’s see how to use the HTML Tag as a selector to add the copy button.
Top ↑In this example, we are going to add the copy button to the List Block from the demo page.
Click on Inspect element
Here, We can see the HTML tag for the list is the ul
tag.
To add the copy button with the HTML Tag selector, do it as:
You’ll see the add new screen something as below:
We are going to add the text as:
ul
, p
, h2
, etc. The Copy button will added to all those HTML tags.)Great! We just have added the copy button to all those elements where the ul tag exists.
Top ↑Just refresh the page, and you can see the Copy Code button added to the Preformatted from the demo page.
See the below video for reference:
Top ↑In the above example, we can see that by adding the ul
HTML tag selector the copy button added to all the UL tags.
But, We want to target the UL tag from the post content.
So, You can do it by adding the parent selector as well.
E.g.
In the above video, we find the parent element of our target ul
tag.
We found that the parent div is the <div class="entry-content">
.
So, We used the class name as a prefix to our UL tag with the dot (.) before the class name:
.entry-content ul
Our copy button was added to all the UL tags from the entry content parent div.
Top ↑Alternatively, You can use the below selectors as well:
Top ↑We are going to add the copy button to the Blockquote Block from the demo page.
See Add the copy button with the CSS class selector.
Top ↑We are going to add the copy button to the Preformatted Block from the demo page.
See Add the copy button with the CSS ID selector.
Join Thousands of Satisfied Customers
Supercharge your content today!