Open In App

Create a Testimonial box switcher using HTML CSS & JavaScript

Last Updated : 23 Jul, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

In this article, we will develop an interactive Testimonial box switcher application using HTML CSS & JavaScript Language.

In this application, we have a Card component that has the message given by the testimonial, also there is information about the person and his/her designation. The card component displays the new testimonial message when the custom buttons to switch between the message boxes are clicked.

Preview of final output: Let us have a look at how the final output will look like.

Screenshot-2023-10-05-at-17-11-56-Testimonial-Box-Switcher-Using-HTML-CSS-&-JavaScript-min-min

Prerequisites:

Approach:

  • Create a HTML strcuture by usng the HTML tags. We have used h1 to represent the GeeksforGeeks heading and h3 for the Application Name. We have created the testimonal conatiner by using the <div> class.
  • There is external styling file which contains all the styling code for each compoenent of the application. The colurs, efffects, padding, heght width all these is been defined and manage in the styling code file.
  • In the JavaScript code, we have defined the data of the testiomanl messages. This includes image, name, message and the designation of the perforn. Then we are stroing the referece of HTML testimonal-cont element to display the message and information there.
  • In the disTestimonial() function, we are rendering the testimonal messahe along with the other information.

Example: Below is the implementation of the above above

HTML
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible"
		content="IE=edge">
	<meta name="viewport"
		content="width=device-width, 
				initial-scale=1.0">
	<title>
	Testimonial Box Switcher 
	Using HTML CSS & JavaScript
</title>
	<link rel="stylesheet" href="styles.css">
</head>
<body>
	<div class="container">
		<header>
			<h1 class="title">
			GeeksforGeeks
			</h1>
			<h3 class="switcher">
			Testimonial Box Switcher using 
			HTML CSS & JavaScript
		</h3>
		</header>
		<div id="testimonial-cont"
			class="testimonial-container">
		</div>
		<button id="prev"><</button>
		<button id="next">></button>
	</div>
	<script src="script.js"></script>
</body>
</html>
CSS JavaScript

Output:


Next Article

Similar Reads