1

I want to add different colors to one post title that I just published on blogspot / Blogger, I have tried using nth-type etc., but it doesn't work properly. Please help me on this.

I have made a picture, more or less like this:

how to make this

1 Answer 1

1

You can use pseudo class :first-child to select first post title as the following

.post:first-child .post-title a { color: red }

Update:

If elements are not in the same container you can use javaScript selector

Add this before </body> tag to select the first .post-title

<script>
   document.querySelector('.post-title a').style.color = 'red';
</script>
5
  • I tried it on my blog ( cobadownload1.blogspot.com ), and all the title colors turned red
    – John Anes
    Commented Dec 15, 2018 at 16:33
  • Ok, because your post divs are not in the same container. see update
    – user137663
    Commented Dec 15, 2018 at 17:30
  • thank you, it works. one more thing I want to ask, how to add the word "update" at the beginning of the title, but for one recent post. like using :: before
    – John Anes
    Commented Dec 15, 2018 at 17:41
  • Ok, in this case you need to add more than one property to the first title and this is not a good thing using JS, My advice is to add class name first-post by JS then use CSS to add more properties. document.querySelector('.post-title a').classList.add('first-title');
    – user137663
    Commented Dec 15, 2018 at 17:49
  • And after that you can use CSS like this .first-title:before { content: "Update" } also .first-title { color: red }
    – user137663
    Commented Dec 15, 2018 at 17:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.