<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
* {box-sizing: border-box}
body {font-family: "Lato", sans-serif;}
/* Style the mytab */
.mytab {
float: left;
border: 1px solid #ccc;
background-color: #f1f1f1;
width: 30%;
height: 300px;
}
/* Style the buttons inside the mytab */
.mytab button {
display: block;
background-color: inherit;
color: black;
padding: 22px 16px;
width: 100%;
border: none;
outline: none;
text-align: left;
cursor: pointer;
transition: 0.3s;
font-size: 17px;
}
/* Change background color of buttons on hover */
.mytab button:hover {
background-color: #ddd;
}
/* Create an active/current "mytab button" class */
.mytab button.active {
background-color: #ccc;
}
/* Style the mytab content */
.mytabcontent {
float: left;
padding: 0px 12px;
border: 1px solid #ccc;
width: 70%;
border-left: none;
height: 300px;
}
</style>
</head>
<body>
<h2>Vertical mytabs</h2>
<p>Click on the buttons inside the mytabbed menu:</p>
<div class="mytab">
<button class="mytablinks" onclick="openCity(event, 'India')" id="defaultOpen">India</button>
<button class="mytablinks" onclick="openCity(event, 'America')">America</button>
<button class="mytablinks" onclick="openCity(event, 'Africa')">Africa</button>
</div>
<div id="India" class="mytabcontent">
<h3>India</h3>
<p>India is the capital city of England.</p>
</div>
<div id="America" class="mytabcontent">
<h3>America</h3>
<p>America is the capital of France.</p>
</div>
<div id="Africa" class="mytabcontent">
<h3>Africa</h3>
<p>Africa is the capital of Japan.</p>
</div>
<script>
function openCity(evt, cityName) {
var i, mytabcontent, mytablinks;
mytabcontent = document.getElementsByClassName("mytabcontent");
for (i = 0; i < mytabcontent.length; i++) {
mytabcontent[i].style.display = "none";
}
mytablinks = document.getElementsByClassName("mytablinks");
for (i = 0; i < mytablinks.length; i++) {
mytablinks[i].className = mytablinks[i].className.replace(" active", "");
}
document.getElementById(cityName).style.display = "block";
evt.currentTarget.className += " active";
}
// Get the element with id="defaultOpen" and click on it
document.getElementById("defaultOpen").click();
</script>
</body>
</html>