I'm looking to dynamically change the content on my webpage by clicking a button, but I'm unsure of how to achieve this using just HTML and CSS. Do I need to utilize another web development language like JavaScript?
Currently, I have two buttons - Button 1 and Button 2. When Button 2 is clicked, I want to update the content within the body element.
Here's a snippet of my HTML:
.body {
//position: absolute;
opacity: 0.9;
//position: relative;
margin-left: 250px;
width: 800px;
height: 1200px;
background-color: gray;
box-shadow: 10px 10px 5px blue;
border-radius: 25px;
border: 2px solid #a1a1a1;
}
a.button {
width: 60px;
height: 20px;
margin-left: 260px;
margin-top: 30px;
display: inline-block;
outline: none;
color: white;
background: #383838;
cursor: pointer;
text-color: white;
text-align: center;
text-decoration: none;
font: bold 14px/100% Arial, Helvetica, sans-serif;
And here's a section from my CSS:
<div class="button">BUTTON 1</a>
</div>
<div class="food">BUTTON 2</a>
<div class="body">Helloooooooo</div>
If anyone has any insight or tips on how to make this functionality work as desired, I would greatly appreciate it!