Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
Advanced Search
  • 0

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


DevDotEXE

Question

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
  • Answers 2
  • Created
  • Last Reply

Top Posters For This Question

Popular Days

Top Posters For This Question

2 answers to this question

Recommended Posts

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

sf-digital-signature-logo-email145.png.46606a2288a2847f44d81b9b7b58f3a5.png
Hi! I'm Paul, an independent Squarespace Consultant since 2007 and founder of SF Digital, building the features that Squarespace didn't include. Our mini-extensions allow you to pick dates in any format, show prices in other currencies, take orders without payment or improve your cartI value honesty, integrity, transparency and respect . Links in my posts may refer to SF Digital products or may be affiliate links.

Link to comment
  • 0
Posted (edited)

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