function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Megha SachaniaMegha Sachania 

What is the alternative for .THIS in component's css in aura

Best Answer chosen by Megha Sachania
VinayVinay (Salesforce Developers) 
Hi Megha,

As far I know there is no alternate for .THIS in CSS.

Add  .THIS CSS class to all top-level elements in the lightning component. It effectively adds namespacing to CSS and helps prevent one component’s CSS from blowing away another component’s styling.  If you are not using .THIS class for all top-level element then framework throws an error.

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar

All Answers

VinayVinay (Salesforce Developers) 
Hi Megha,

As far I know there is no alternate for .THIS in CSS.

Add  .THIS CSS class to all top-level elements in the lightning component. It effectively adds namespacing to CSS and helps prevent one component’s CSS from blowing away another component’s styling.  If you are not using .THIS class for all top-level element then framework throws an error.

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.

Thanks,
Vinay Kumar
This was selected as the best answer
AnudeepAnudeep (Salesforce Developers) 
Hi Megha, 

I don't think there is an alternative. All of the CSS selectors need to include “.THIS”: and it is required. Failure to do so will give the below error

User-added image

You can learn more about this here

If you find this information helpful, please mark this answer as Best. It may help others in the community
 
Megha SachaniaMegha Sachania
Thanks For the help Anudeep and vinay