Jump to content

Best practice for applying CSS to hundreds of block IDs across several pages?

Recommended Posts

Site URL: https://watermelon-koala-napg.squarespace.com/bio-archidex

Hello! I'm a decent programmer, although brand new to web dev and Squarespace.

I'm working on a website and have ~50 pages that all need to be styled in the same way. Each page has roughly 6-7 blocks that need custom CSS (identical across those pages), and there will be more of these pages in the future. These block types are used in several other ways in those pages though, so they can't be edited on a block-type basis.

I'm curious if there are recommended best practices for how to handle this.

As far as I can tell, the first obvious option is putting the CSS in the Custom CSS Editor, which would centralize any future changes, but create a gigantic list of 300+ impossible-to-parse block ID references. The second option is to duplicate the CSS on each page in a Code Block, which creates isolated, clean code, but will require 50+ edits for any future changes.

The ideal would be some way to tag blocks for targeted CSS, so each block with common CSS has a shared ID of some sort, and then I just apply CSS to that ID in the CSS Editor. There doesn't seem to be an immediately obvious way to do that though.

Any suggestions for how to approach the above?

Thanks for your help!

Edited by DevDotEXE
Link to comment
  • Replies 2
  • Views 284
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

1 hour ago, DevDotEXE said:

I'm working on a website and have ~50 pages that all need to be styled in the same way. I'm curious if there are recommended best practices for how to handle this.

As far as I can tell, the first obvious option is putting the CSS in the Custom CSS Editor, which would centralize any future changes, but create a gigantic list of 300+ impossible-to-parse block ID references.

It's difficult to understand why you would need to target block IDs, except in a few rare circumstances, so I'd like to understand more about the specifics. Please provide us with a working link to some of the pages and explain what you need to change and why. 

If the site isn't live, you'll need to set a public password in the visibility settings and share it with us, otherwise we won't be able to view it.

About me: I've been a SQSP User for 18 yrs. I was invited to join the Circle when it launched in 2016. I have been a Circle Leader since 2017. I don't work for Squarespace. I value honesty, transparency, diversity and good design ♥.
Work: I founded and run SF.DIGITAL, building Squarespace Extensions to supercharge your commerce website. 
Content: Views and opinions are my own. Links in my posts may refer to SF.DIGITAL products or may be affiliate links.
Forum advice is free. You can thank me by clicking one of the feedback emojis below. Coffee is optional.

Link to comment

For sure -- I just added a link to the question above. Password: singularity

It's for an upcoming game and there are many character pages formatted like the above.

It's very much WIP, but so far I've applied CSS for borders on the markdown block, clipping paths to tighten the borders, and height, width, and alignment to preserve good structure on mobile and tweak block spacing, etc. I anticipate I'll need to do quite a bit more targeted CSS before the design is really wrung out, unless I'm going about this in entirely the wrong way.

The current setup is that all the block-specific CSS is contained in a code block at the bottom of the page.

Thanks for the help!

Edited by DevDotEXE
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • 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.