- Create a Quiz App using HTML CSS & JavaScript
- Full Video Tutorial of Background Image Slider
- Create a Quiz App using HTML CSS & JavaScript [Source Codes]
- # HTML CODE
- # CSS CODE
- # JS CODE
- You answered $/$ questions correctly
- Create a Quiz App with Timer using HTML CSS & JavaScript
- Video Tutorial of Create a Quiz App with Timer
Create a Quiz App using HTML CSS & JavaScript
Hello , Today in this blog you’ll learn How to Create a Quiz App using HTML CSS & JavaScript . Earlier I have shared a blog on Background Image Slider Using Html Css & javascript and now it’s time to Create a Quiz App.
If you are familiar with HTML CSS & JAVASCRIPT then you can easily create this Create a Quiz App using HTML CSS & JavaScript . Those People who are feeling difficult to understand this, don’t worry You can watch a full video tutorial on this Quiz App .
Full Video Tutorial of Background Image Slider
Create a Quiz App using HTML CSS & JavaScript [Source Codes]
To create this Quiz App First, you need to create Three files, HTML File CSS File And JAVASCRIPT File. After creating these files Just copy the given source code and paste into your text editor and edit it according to your requirement. You can also download the source code files of this Quiz App using HTML CSS & JavaScript from the given download button.
# HTML CODE
First, create a Html file (index.html) and paste the given codes in your CSS file.
# CSS CODE
Second, you create an CSS file (style.css) and paste the given codes in your CSS file.
/* coding with nick */ @import url(‘https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500&display=swap’); * < box-sizing: border-box; >body < background-color: #b8c6db; background-image: linear-gradient(315deg, #b8c6db 0%, #f5f7f7 100%); font-family: 'Poppins', sans-serif; display: flex; align-items: center; justify-content: center; height: 100vh; overflow: hidden; margin: 0; >.quiz-container < background-color: #fff; border-radius: 10px; box-shadow: 0 0 10px 2px rgba(100, 100, 100, 0.1); width: 600px; overflow: hidden; >.quiz-header < padding: 4rem; >h2 < padding: 1rem; text-align: center; margin: 0; >ul < list-style-type: none; padding: 0; >ul li < font-size: 1.2rem; margin: 1rem 0; >ul li label < cursor: pointer; >button < background-color: #03cae4; color: #fff; border: none; display: block; width: 100%; cursor: pointer; font-size: 1.1rem; font-family: inherit; padding: 1.3rem; >button:hover < background-color: #04adc4; >button:focus
# JS CODE
Last, create a JavaScript file ( script.js ) and paste the given codes in your JavaScript file.
const quizData = [ < question: "Which language runs in a web browser?", a: "Java", b: "C", c: "Python", d: "javascript", correct: "d", >, < question: "What does CSS stand for?", a: "Central Style Sheets", b: "Cascading Style Sheets", c: "Cascading Simple Sheets", d: "Cars SUVs Sailboats", correct: "b", >, < question: "What does HTML stand for?", a: "Hypertext Markup Language", b: "Hypertext Markdown Language", c: "Hyperloop Machine Language", d: "Helicopters Terminals Motorboats Lamborginis", correct: "a", >, < question: "What year was JavaScript launched?", a: "1996", b: "1995", c: "1994", d: "none of the above", correct: "b", >, ]; const quiz= document.getElementById('quiz') const answerEls = document.querySelectorAll('.answer') const questionEl = document.getElementById('question') const a_text = document.getElementById('a_text') const b_text = document.getElementById('b_text') const c_text = document.getElementById('c_text') const d_text = document.getElementById('d_text') const submitBtn = document.getElementById('submit') let currentQuiz = 0 let score = 0 loadQuiz() function loadQuiz() < deselectAnswers() const currentQuizData = quizData[currentQuiz] questionEl.innerText = currentQuizData.question a_text.innerText = currentQuizData.a b_text.innerText = currentQuizData.b c_text.innerText = currentQuizData.c d_text.innerText = currentQuizData.d >function deselectAnswers() < answerEls.forEach(answerEl =>answerEl.checked = false) > function getSelected() < let answer answerEls.forEach(answerEl => < if(answerEl.checked) < answer = answerEl.id >>) return answer > submitBtn.addEventListener('click', () => < const answer = getSelected() if(answer) < if(answer === quizData[currentQuiz].correct) < score++ >currentQuiz++ if(currentQuiz < quizData.length) < loadQuiz() >else < quiz.innerHTML = `You answered $/$ questions correctly
` > > >)
That’s all, now you’ve successfull Quiz App using HTML CSS & JavaScript . If your code doesn’t work or you’ve faced any error And problem’s , please download the source code from the given download button.
I Hope this blog will be helpful.
Create a Quiz App with Timer using HTML CSS & JavaScript
Hello readers, Today in this blog you’ll learn how to Create a Quiz Application with Timer using HTML CSS & JavaScript. Earlier I’ve shared a blog on how to Create a Responsive Personal Portfolio Website and now it’s time to create Quiz Web App using JavaScript.
In this program [Quiz App with Timer], there are three layers or boxes, and these boxes shown one by one on a particular button clicked. At first, on the webpage, there is shown a button labeled as “Start Quiz” and when you clicked on that button, then the info box appears with popup animation.
In this infobox, there are some rules of the quiz and two buttons labeled as “Exit” and “Continue”. When you clicked on the Exit button, the info box will be hidden but when you clicked on the Continue button, then the Quiz Box appears.
In the Quiz Box, there is a header with a title on the left side and a timer box on the right side. This timer starts decrement from 15 to 0 sec and there is also shown a timeline indicator that is sliding from the left to right side according to the timer. If the user selects an option between 15 to 0 sec, the timer will be stopped and all available options will be disabled.
If the user selected option is correct, the selected option color, background color changed to green and there is also shown the tick icon to inform the user that the selected answer is correct. If the user selects an option that is incorrect, the selected option color, background color changed to red and there is shown the cross icon to inform the user that the selected option is incorrect and the correct option will be automatically selected.
If the user doesn’t select an option between 15 to 0 sec, the timer will be stopped once it comes in 0 and the correct option of that question will be selected automatically. After that, there is the next button to show the next question, and there is a total of five questions on this Quiz.
In the end, the result box will be appeared and shown the user score and two buttons [Replay Quiz, Quit Quiz], if the user clicked on the replay quiz button, the quiz will again start with the number 1 question, and the score of the user will be 0 but if the user clicked on the quit quiz button, the current window will be reloaded and the quiz starts from the begin.
Video Tutorial of Create a Quiz App with Timer
In the video, you have seen the actual preview of the Quiz Application with Timer and I hope you’ve understood the codes behind creating this Quiz Box layout. In this video, I’ve only written the HTML & CSS codes, and in the second part of this video, I’ve completed the JavaScript codes of this program. If you haven’t watched part 2 of this video, click here to watch it now.
You can use this Quiz and also you can add more questions to this Quiz. In the source codes, I’ve written many comments on how you can add more questions and explained each JavaScript line of this Quiz. If you’re a beginner, you may have difficulties understanding the JavaScript codes but you can easily understand the HTML & CSS codes and I’ve tried to explain all JavaScript line with comments, hope you will understand.
To create this program (Quiz Application with Timer). First, you need to create four Files one HTML File, CSS File and the other two are JavaScript files. After creating these files just paste the following codes in your file.
First, create an HTML file with the name of index.html and paste the given codes in your HTML file. Remember, you’ve to create a file with .html extension.
Some Rules of this Quiz1. You will have only 15 seconds per each question.2. Once you select your answer, it can't be undone.3. You can't select any option once time goes off.4. You can't exit from the Quiz while you're playing.5. You'll get points on the basis of your correct answers. Awesome Quiz ApplicationTime Left15