# Add optional field "ID" to forms which will render a CSS ID on the front end which can then be styled

**URL:** <https://forums.knack.com/t/add-optional-field-id-to-forms-which-will-render-a-css-id-on-the-front-end-which-can-then-be-styled/14180>\
**Category:** Feature Requests\
**Created:** [April 30, 2023, 9:03am UTC](https://forums.knack.com/t/add-optional-field-id-to-forms-which-will-render-a-css-id-on-the-front-end-which-can-then-be-styled/14180 "2023-04-30T09:03:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![GSH](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/gsh/32/2669_2.png) [@GSH](https://forums.knack.com/u/GSH)\
**Post date:** [April 30, 2023, 9:03am UTC](https://forums.knack.com/t/add-optional-field-id-to-forms-which-will-render-a-css-id-on-the-front-end-which-can-then-be-styled/14180/1 "2023-04-30T09:03:37Z")

</div>

If you could add an ID to a view which then encapsulated the view (form, table etc) on the front end within it’s own CSS class, it would make it possible to style it.

Add ability to assign these to different user roles so each user role could have a different style too.

---

<div class="post-metadata">

**Author:** ![KnackPros](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/knackpros/32/807_2.png) [@KnackPros](https://forums.knack.com/u/KnackPros)\
**Post date:** [April 30, 2023, 9:26pm UTC](https://forums.knack.com/t/add-optional-field-id-to-forms-which-will-render-a-css-id-on-the-front-end-which-can-then-be-styled/14180/2 "2023-04-30T21:26:53Z")

</div>

Hi @GSH,

Views are selectable by id. For example

```auto
#view_123 {
  /* CSS styles for view_123 */
}

```

If your goal is for each user role to have a different style, you can save those styles as CSS classes, then apply them to the views accessible by that role. For example:

```auto
/* CSS */
.role_1 {
  /* Insert CSS styles for role_1 */
}
.role_2 {
  /* Insert CSS styles for role_2 */
}

// Javascript.
// This code will run on all views.
$(document).on('knack-view-render.any', function(event, view, data) {
  // 1. Get roles who can access this view.
  // 2. Add CSS class for each role to the view.
})

```

Hope this helps.

-Ian

---

<div class="post-metadata">

**Author:** ![GSH](https://sea2.discourse-cdn.com/flex020/user_avatar/forums.knack.com/gsh/32/2669_2.png) [@GSH](https://forums.knack.com/u/GSH)\
**Post date:** [May 1, 2023, 3:24pm UTC](https://forums.knack.com/t/add-optional-field-id-to-forms-which-will-render-a-css-id-on-the-front-end-which-can-then-be-styled/14180/3 "2023-05-01T15:24:56Z")

</div>

Thank you for that explanation.
