Jump to content

Style paragraph link within code block

Recommended Posts

Site URL: https://life-of-charlie.squarespace.com/blog/game-changing-skincare

I've used custom CSS to implement a drop cap on the first letter of the first paragraph of a blog post. To do so, I applied a class to the entire first block of text using a code block, up until the first non-text element (an image, in this case), to prevent inconsistent spacing between paragraphs (code blocks have a bit more padding).

However, it appears that links within the text in that code block are not inheriting the same styling as all other links. Is there an issue with how I've created the link? Or a way to force 

p a {}

elements within a code block to inherit Squarespace's default link styling via CSS?


Site is currently password-protected, use code buildout.


Blog drop cap no link styling.png

Code block HTML 2.png

Code block HTML 1.png

Blog text with proper link styling.png

Link to comment
  • Replies 3
  • Views 2k
  • Created
  • Last Reply

The reason is due to CSS specificity. See screenshot. To override you could use a higher specificity using the following CSS:

.blog-item-wrapper .blog-item-content p a {
  /* add css here to override */



Full stack developer who loves helping people out with anything web related. If you'd like to support me, buy me a coffee!

Link to comment

Thank you for that! For others' reference, I used the following

.blog-item-wrapper .blog-item-content p a {
  color: @accent;
  background-repeat: repeat-x;
  background-image: linear-gradient(to right,currentColor 180%,currentColor 0);
  background-size: 1px 1px;
  background-position: 0 100%;
  white-space: initial;

to override all link styling in the blog post paragraphs, regardless of whether or not they were within the code block. In this case, @accent is assigned to the hex code of my palette accent color.


Link to comment
  • 9 months later...


This topic is now archived and is closed to further replies.

  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.