<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Be My Valentine</title> <style> body { font-family: Arial, sans-serif; background-color: #f8f8f8; text-align: center; } #container { margin: 100px auto; padding: 20px; width: 80%; max-width: 600px; background-color: #fff; border-radius: 10px; box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); } h1 { color: #ff4d4d; } #valentine-form { margin-top: 20px; } input[type="text"], input[type="submit"] { padding: 10px; width: calc(100% - 22px); margin-bottom: 10px; border: 1px solid #ccc; border-radius: 5px; box-sizing: border-box; } input[type="submit"] { background-color: #ff4d4d; color: #fff; cursor: pointer; } input[type="submit"]:hover { background-color: #ff6666; } .confetti { position: absolute; width: 10px; height: 10px; background-color: #ff4d4d; border-radius: 50%; animation: confetti-fall 3s ease-out infinite; } @keyframes confetti-fall { 0% { transform: translateY(-100vh) rotate(0deg); } 100% { transform: translateY(100vh) rotate(360deg); } } </style> </head> <body> <div id="container"> <h1>Will you be my Valentine?</h1> <form id="valentine-form" action="#"> <input type="text" id="name" placeholder="Your Name" required><br> <input type="submit" id="valentine-button" value="Yes, I will!"> </form> </div> <script> // Attach the event listener to the button outside of the click event handler document.getElementById('valentine-button').addEventListener('click', function(event) { event.preventDefault(); generateConfetti(); }); function generateConfetti() { for (let i = 0; i < 50; i++) { let confetti = document.createElement('div'); confetti.classList.add('confetti'); confetti.style.left = Math.random() * window.innerWidth + 'px'; confetti.style.animationDuration = Math.random() * 3 + 2 + 's'; document.body.appendChild(confetti); setTimeout(() => { confetti.remove(); }, 2000); } } </script> </body> </html>
Write, Run & Share HTML code online using OneCompiler's HTML online Code editor for free. It's one of the robust, feature-rich online Code editor for HTML language, running on the latest version HTML5. Getting started with the OneCompiler's HTML compiler is simple and pretty fast. The editor shows sample boilerplate code when you choose language as HTML
. You can also specify the stylesheet information in styles.css
tab and scripts information in scripts.js
tab and start coding.
HTML(Hyper Text Markup language) is the standard markup language for Web pages, was created by Berners-Lee in the year 1991. Almost every web page over internet might be using HTML.
<!DOCTYPE html>
<html>
and ends with </html>
<h1>
to <h6>
where <h1>
is the highest important heading and <h6>
is the least important sub-heading.<p>..</p>
tag.<a>
tag.
<a href="https://onecompiler.com/html">HTML online compiler</a>
<img>
tag, where src
attribute consists of image name.<button>..</button>
tag<ul>
for unordered/bullet list and <ol>
for ordered/number list, and the list items are defined in <li>
.<a href="https://onecompiler.com/html">HTML online compiler</a>
CSS(cascading style sheets) describes how HTML elements will look on the web page like color, font-style, font-size, background color etc.
Below is a sample style sheet which displays heading in green and in Candara font with padding space of 25px.
body{
padding: 25px;
}
.title {
color: #228B22;
font-family: Candara;
}
<table>
tag.<tr>
tag<th>
tag<td>
tag<caption>
tag<script>
is the tag used to write scripts in HTML<script src="script.js"></script>