how to apply css to a link within a particular div only?

Tags: javascript,jquery,css

Problem :

Here is my situation. I have 3 divs on my website. There is a button in each of divs. Here is my codes :

<div id="gg1">
  <a class="btn">
<div id="gg2">
  <a class="btn">
<div id="gg3">
  <a class="btn">

May I know how to apply css style to 1 button only without effect on other 2 buttons Css or Jquery? Note that I cannot change the class and id of the buttons.

Solution :

Use a descendant selector:

#gg1 a.btn {
    /* styles here affect only a.btn elements within #gg1 */

    CSS Howto..

    CSS how to change color of a specific primary-panel in a if-block

    Bootstrap 3 - How to maximize input width inside navbar

    How do I make LessCSS output css which is then uploaded to webserver

    How do you set a JavaScript onclick event to a class with css

    How could I have an iframe that shows the target page and all it's elements at 50% scale?

    How to override overridden class — CSS

    How do I make it impossible to highlight text using CSS?

    How to add spacing in between

    How to float a word next to animated text

    CSS select: how to count and select child of a specific class only?

    How to make responsive video background in DIV container with dynamic height?

    How to change content of css using jQuery toggle

    How to get better at CSS, laying out designs and UI Programming? [closed]

    How to show hidden content when hover in CSS not working

    how to override font-color dynamically with css color property

    How to create and manage large CSS projects?

    How to id dom table so I can position it on page?

    How to create dynamic business listings in wordpress [closed]

    HTML - How to do a square plain button while using jQuery Mobile css [closed]

    how to create bar code like in a horizontal line using css (For Email)

    how to properly resize navbar fixed in bootstrap

    D3 Line Chart Show/Hide Element, Variable Not Defined Error?

    How can I align a button at the bottom of a div?

    Ruby on Rails: (Beginner) How can I make my style sheet (in public/stylesheet folder) be used by my layouts?

    How to enable HTML content on top of Flash content without the frame rate dropping?

    How to float

    to bottom of a

    when you can't use position:relative and position:absolute

    How to horizontally center align a span inside a div

    CSS- How'd they do that without Absolute Positioning and Z-index?

    How to add space between elements (but not outside of them) using CSS?

    How to get the position of element transformed with css rotate