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 to center vertically child elements inside div [duplicate]

    How to change the width of dynamically generated list boxes, based on user input?

    CSS how to target element beside my current element?

    How do I apply the following CSS to only the Parent nodes of a Kendo Tree View?

    How to specify a more specific styling with .css.scss?

    How to add a gradient/filter in the image in CSS

    How to make Instagram.js feed responsive in Bootstrap?

    How to CSS style a table such that its width is within [min, max] percent of page width and as wide as necessary?

    How to set backround image in css

    How can I avoid div from executing new line if one line is already full?

    How To Insert Some Content Before An HTML Element In The Runtime Using CSS

    How to control cursor/caret size with CSS

    How do I assign a class to a jquery button var

    How can menu items be displayed from bottom up using CSS

    How to make pixel perfect font in css?

    How to add bootstrap css to my Wordpress plugin

    How can I have a tile-able area to the left and right of a div?

    How to center the navigation on a drop down menu?

    How to make a bullet list align with text in css?

    How to use CSS transition to animate dropdown menu?

    How to position iframe (calendar) inside php echo statement?

    How to scale a fixed-width website to an iPad viewport

    How to hide specific TD borders in a TABLE using CSS

    How to know which CSS style is applied and from where (javascript)?

    How to make this CSS compatible with IE browsers? [closed]

    How to align TH Header with TD in TBody

    How to apply an effect of white lines crossed to a div with css

    how to show background image(multiple) if out of current div

    How to reduce space between unordered list and its previous element(center)?

    How to get GWT console/development mode to generate css errors?