E
E
eldar_web2015-10-28 09:23:47
css
eldar_web, 2015-10-28 09:23:47

How can rows (tr) be made links in HTML in a table?

I wrote a before tr, but it does not accept these tags. How can a solution be found?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
C
Cat Anton, 2015-10-28
@eldar_web

I wrote a before tr, but it does not accept these tags.

You can't do this, because tr can only lie inside a table, tbody, thead or tfoot:
www.w3.org/TR/html5/tabular-data.html#the-tr-element
codepen.io/27cm/pen/MaGmdQ
<style>
.table {
    display: table;
}

.table > a {
    display: table-row;
}

.table > a > div {
    display: table-cell;
}
</style>
<div class="table">
    <a href="#">
        <div>1-1</div><div>1-2</div><div>1-3</div>
    </a>
    <a href="#">
        <div>2-1</div><div>2-2</div><div>2-3</div>
    </a>
</div>

JavaScript option:
<table>
    <tr onclick="document.location = 'example.com';">
        <td>1-1</td><td>1-2</td><td>1-3</td>
    </tr>
    <tr onclick="document.location = 'example.com';">
        <td>2-1</td><td>2-2</td><td>2-3</td>
    </tr>
</table>

S
SMAILAIMEN, 2015-10-28
@SmaiLaimen

href="#">NAME

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question