# (Squarespace) How to Assign Class Name for Section?

**URL:** <https://community.elfsight.com/t/squarespace-how-to-assign-class-name-for-section/28374>\
**Category:** Platform Tips\
**Tags:** squarespace\
**Created:** [December 1, 2023, 3:59am UTC](https://community.elfsight.com/t/squarespace-how-to-assign-class-name-for-section/28374 "2023-12-01T03:59:21Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tuanphan](https://sea2.discourse-cdn.com/flex020/user_avatar/community.elfsight.com/tuanphan/32/3165_2.png) [@tuanphan](https://community.elfsight.com/u/tuanphan)\
**Post date:** [December 1, 2023, 3:59am UTC](https://community.elfsight.com/t/squarespace-how-to-assign-class-name-for-section/28374/1 "2023-12-01T03:59:21Z")

</div>

When you need to target a section in Squarespace, you will need to use [data-section-id].  
When you need code that affects multiple sections, you will need to use [data-section-id1], [data-section-id2,…

If you intend to build templates to sell to customers, your customers will need to learn how to find data-section-id, which will be annoying for them.

You can use this code to assign a class name to a specific section  
First, add a Code Block to section where you want to assign class name

```auto
<div class="section1"></div>

```

Next, add this code to Website Tools \> Code Injection \> Footer

```auto
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.7.0/jquery.min.js"></script>
<script>
 jQuery(document).ready(function($){
  $(".code-block .section1").parents(".page-section").addClass("section1");
  $('.code-block .section1').parents('.code-block').addClass('hide-code-block');
 })
</script>
<style>
.hide-code-block {
        display: none !important;
}
</style>

```

These code mean

- Find a Code Block, if Code Block code contains class “section1”, then add this class name to Section Tag
- Find a Code Block, if Code Block code contains class “section2”, then add class name: hide-code-block
- Remove Code Block

and when you want to use data-section-id, just use this class name instead

```auto
section.section1

```
