JSFiddle - React, Tailwind, and code Playground
HTML
<p id="insert"></p>
SCSS
p {
font-size: 2rem;
text-align: center;
span {
&:first-child,
&:nth-child(4) {
color: #4285f4;
}
&:nth-child(2),
&:nth-child(6) {
color: #ea4335;
}
&:nth-child(3) {
color: #fbbc07;
}
&:nth-child(5) {
color: #34a854;
}
}
}
JavaScript
const insertTag = (target, word) => {
for(const character of word) {
document.querySelector(target).innerHTML += `<span>${character}</span>`;
}
}
insertTag('#insert', 'Google');