I want to implement a page control which does not use javascript. The idea is to use the input:checked + <element> selector. Showing only the selected page is no problem, but it seems not to be possible to have both: active tab and page.
May be it is possible to activate two radiobuttons at once with a label without using javascript?
input {
position: absolute;
width: 0;
height: 0;
}
.tabs {
display: flex;
}
.tabs > label,
.pages {
padding: 10px;
background-color: #eee;
border: 1px solid #ddd;
}
.tabs > input:checked + label {
background-color: green;
}
.tabs > label {
border-bottom: none;
border-right-width: 0;
}
.tabs > label:last-child {
border-right-width: 1px;
}
.pages > div {
display: none;
}
.pages > input:checked + div {
display: block;
}
<div class="tabs">
<input type="radio" name="tab" id="tab1" checked="checked">
<label for="page1">First Tab</label>
<input type="radio" name="tab" id="tab2">
<label for="page2">Second Tab</label>
<input type="radio" name="tab" id="tab3">
<label for="page3">Third Tab</label>
</div>
<div class="pages">
<input type="radio" name="page" id="page1" checked="checked">
<div>Page Content #1</div>
<input type="radio" name="page" id="page2">
<div>Page Content #2</div>
<input type="radio" name="page" id="page3">
<div>Page Content #3</div>
</div>
The page control itself is working here. But I want to highlight the active tab. Please note: I don't want to use js (it's easy with js). I don't want to use any lib. The html and css structure can be changed in any way to reach the goal.