Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how do I give a link name to an html table row?

Tags:

html

hyperlink

I have a table with each row explaining something (an input command). In another place, I am saying from this state with that input command, you go that other state. What I want to do is to link the that input command to the appropriate row of the table. Imagine something like this:

...link to row number <a href="#row2">2</a>...

<table ...>
    <tr>
        <td>command</td>
        <td>description</td>
    <tr>
    <tr>
        <a name="row1"></a>
        <td>A</td>
        <td>input A</td>
    <tr>
    <tr>
        <a name="row2"></a>
        <td>B</td>
        <td>input B</td>
    <tr>
</table>

As you can see, I tried putting a <a name="row2"></a> in the <tr> block but that didn't work (it brings me to the top of the table)

Is what I want to do possible?

like image 648
Shahbaz Avatar asked Sep 23 '11 14:09

Shahbaz


3 Answers

You do one of two things:

1) Set the id attribute of the <tr>. <tr id="row2">...</tr>

OR

2) put the <a> element inside the <td> element. If you put any element inside a <table> but not inside a <th> or <td>, it'll get rendered before the entire table (try it with any element, the browser does its best to correct the invalid HTML)

like image 184
J. Holmes Avatar answered Nov 14 '22 02:11

J. Holmes


Although non-intuitive for me, but I put the <a name="row2"></a> inside the first <td> block and it worked!

like image 32
Shahbaz Avatar answered Nov 14 '22 01:11

Shahbaz


<tr>
    <td><a name="row2"></a></td>
    <td>B</td>
    <td>input B</td>
<tr>
like image 32
aus Avatar answered Nov 14 '22 02:11

aus