---
title: "How to get access to “CssClass” property for server element isn't WebControl in ASP.NET?"  
description: "How to get access to “CssClass” property for server element isn't WebControl in ASP.NET?"  
author: "Anonymous User"  
published: 2014-12-11  
updated: 2014-12-12  
canonical: https://www.mindstick.com/forum/12787/how-to-get-access-to-cssclass-property-for-server-element-isn-t-webcontrol-in-asp-dot-net  
category: "asp.net"  
tags: ["c#", "asp.net mvc", "css"]  
reading_time: 1 minute  

---

# How to get access to “CssClass” property for server element isn't WebControl in ASP.NET?

I have ordinary div like this:

<div id="myCoolElement" runat="[server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over)"></div>

I want use the [construction](https://www.mindstick.com/articles/167589/the-reasons-why-we-love-construction-jobs-salary) to set CssClass for myCoolElement like this:

myCoolElement.CssClass("mycoolstyle");

But CssClass [property](https://www.mindstick.com/blog/205/property-notification-in-c-sharp) is supported only for WebControls.

How I can set CssClass for my element without creating WebControl?

## Replies

### Reply by Mark Devid

Try this.

myCoolElement.Attributes.Add("class", "mycoolstyle");

### Reply by Anonymous User

You can do like this

myCoolElement.Attributes["class"] = "mycoolstyle";


---

Original Source: https://www.mindstick.com/forum/12787/how-to-get-access-to-cssclass-property-for-server-element-isn-t-webcontrol-in-asp-dot-net

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
