css: How to select first anchor tag inside table


Tags: css,css3

Problem :

 <table id="table">
    <tr>
        <th><a href="main.html">edit</a><th>
        <th><a href="main2.html">update</th>
        <th>........</th>
    </tr>
    <tr>
         blah blah
    </tr>
</table>

Here i want to select the anchor element of first th to add some styiling

I tried

table#table a:first-child{
    color: #888888;
    font-weight: normal;
    text-align: left;
}

but failing



Solution :

Do you mean like this?

HTML:

<table id="table">
    <tr>
        <th><a href="main.html">edit</a>
        </th>
        <th><a href="main2.html">update</a>
        </th>
        <th>........</th>
    </tr>
        <tr>
        <th><a href="main.html">edit</a>
        </th>
        <th><a href="main2.html">update</a>
        </th>
        <th>........</th>
    </tr>
</table>

CSS:

#table th:first-child a {
    color: red;
    font-weight: normal;
    text-align: left;
}

You want to select the first <th> and then find <a>.

DEMO HERE


    CSS Howto..

    How can I position my navigation bar further up on the page?

    How to set border's thickness in percentages?

    How to run PHP through Adobe Muse generated CSS

    How to override default CSS file location in a Qml Webview?

    How to change SVG color (when using the SVG as background in CSS)

    How to add Video from project directory in the background of Div

    How to style google cse

    CSS how to apply :first-child and :last-child

    How to display just part of image on hover?

    How to keep a sticky menu contained inside a floating sidebar?

    How do I allow CSS files to be referenced from other domains?

    Including loads of css files and Javascript file - how do I optimize

    How to position two divs horizontally within another div

    How to style the div to triangle using CSS? [duplicate]

    How do I replace color: windowtext;

    How to get odd/even coloring for IE and Firefox using CSS alone?

    How can I make this menu using only anchor tag and css Not using ul and li?

    How can I modify a CSS class using JavaScript?

    How to get these divs side-by-side while still keeping position:relative and not using float?

    How to achieve a “mini” select style using Bootstrap (or straight CSS)?

    How design an unordered list of images horizontally with Bootstrap?

    How to apply a CSS class on hover to dynamically generated submit buttons?

    How to prevent from text to extend the
  • container height?
  • How to avoid this hardcoded index.js when use webpack?

    How to change the color of an active h5 tab using jQuery or CSS

    CSS: how to stop text from taking up more than 1 line?

    How to remove “pictureframe” in Internet Explorer?

    Need to show submenu to the right of it's parent item

    How to get All Defined CSS Selectors for a given DOM Element?

    How to remove the “Dotted Border” on clicking?