---
title: "How to change the CSS with javascript ?"  
description: "How to change the CSS with javascript ?"  
author: "Aaron Douglas"  
published: 2013-08-19  
updated: 2013-08-19  
canonical: https://www.mindstick.com/forum/1402/how-to-change-the-css-with-javascript  
category: "javascript"  
tags: ["javascript"]  
reading_time: 1 minute  

---

# How to change the CSS with javascript ?

Hi!\

I do not know how to [access](https://www.mindstick.com/articles/12994/how-foreigners-can-access-blocked-websites-in-china) a specific [CSS](https://www.mindstick.com/forum/514/background-gradient-ie7-css-problem) using javascript.

Let us [say](https://answers.mindstick.com/qa/116645/a1-wreckers-reviews-what-do-customers-say),

```
#menu { color: red; }can be accessed bydocument.getElementById('menu').style.color = "blue";But I want to access#menu li a { height: 10%; }
```

How do I access that using document.getElementById() ?

Thanks is [advance](https://www.mindstick.com/blog/33258/jee-mains-and-jee-advance-exams)\

## Replies

### Reply by shreesh chandra shukla

Hi! your answer is this

The .getElementById() function is about getting an element by a unique "id" string. If you need to get elements otherwise, there are other APIs to use: .getElementsByTagName(), .getElementsByClass(), .querySelectorAll(), etc. Browser support varies, and even .getElementById() is different between IE and other browsers.


---

Original Source: https://www.mindstick.com/forum/1402/how-to-change-the-css-with-javascript

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
