JSFiddle - React, Tailwind, and code Playground
HTML
<p>Skill 1, Skill 2, Skill 3</p>
<p>Skill 1</p>
<p> </p>
CSS
.tag {
background-color: lightgray;
padding: 3px;
margin: 3px;
border-radius: 3px;
}
JavaScript
// Converts comma separated string into tags
function convertToTags(s) {
$("p").each(function() {
var words = $(this).text().split(", ");
var total = words.length;
$(this).empty();
for (index = 0; index < total; index++) {
$(this).append($("<span class = 'tag' > ").text(words[index]));
}
})
}
// Calls the function on document ready
$(document).ready(function() {
convertToTags("p");
});