<!doctype html> <html lang="en"> <head> <title class="trn">New Tab</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <style> * { margin: 0; padding: 0; box-sizing: border-box; } html, body { height: 100%; width: 100%; } body { background: black; display: flex; justify-content: center; align-items: center; } .clock { height: 20vh; color: white; font-size: 22vh; font-family: sans-serif; line-height: 20.4vh; display: flex; position: relative; /*background: green;*/ overflow: hidden; } .clock::before, .clock::after { content: ''; width: 7ch; height: 3vh; background: linear-gradient(to top, transparent, black); position: absolute; z-index: 2; } .clock::after { bottom: 0; background: linear-gradient(to bottom, transparent, black); } .clock>div { display: flex; } .tick { line-height: 17vh; } .tick-hidden { opacity: 0; } .move { animation: move linear 1s infinite; } @keyframes move { from { transform: translateY(0vh); } to { transform: translateY(-20vh); } } </style> </head> <body> <div class="clock"> <div class="hours"> <div class="first"> <div class="number">0</div> </div> <div class="second"> <div class="number">0</div> </div> </div> <div class="tick">:</div> <div class="minutes"> <div class="first"> <div class="number">0</div> </div> <div class="second"> <div class="number">0</div> </div> </div> <div class="tick">:</div> <div class="seconds"> <div class="first"> <div class="number">0</div> </div> <div class="second infinite"> <div class="number">0</div> </div> </div> </div> <script> var hoursContainer = document.querySelector('.hours') var minutesContainer = document.querySelector('.minutes') var secondsContainer = document.querySelector('.seconds') var tickElements = Array.from(document.querySelectorAll('.tick')) var last = new Date(0) last.setUTCHours(-1) var tickState = true function updateTime() { var now = new Date var lastHours = last.getHours().toString() var nowHours = now.getHours().toString() if (lastHours !== nowHours) { updateContainer(hoursContainer, nowHours) } var lastMinutes = last.getMinutes().toString() var nowMinutes = now.getMinutes().toString() if (lastMinutes !== nowMinutes) { updateContainer(minutesContainer, nowMinutes) } var lastSeconds = last.getSeconds().toString() var nowSeconds = now.getSeconds().toString() if (lastSeconds !== nowSeconds) { //tick() updateContainer(secondsContainer, nowSeconds) } last = now } function tick() { tickElements.forEach(t => t.classList.toggle('tick-hidden')) } function updateContainer(container, newTime) { var time = newTime.split('') if (time.length === 1) { time.unshift('0') } var first = container.firstElementChild if (first.lastElementChild.textContent !== time[0]) { updateNumber(first, time[0]) } var last = container.lastElementChild if (last.lastElementChild.textContent !== time[1]) { updateNumber(last, time[1]) } } function updateNumber(element, number) { //element.lastElementChild.textContent = number var second = element.lastElementChild.cloneNode(true) second.textContent = number element.appendChild(second) element.classList.add('move') setTimeout(function () { element.classList.remove('move') }, 990) setTimeout(function () { element.removeChild(element.firstElementChild) }, 990) } setInterval(updateTime, 100) </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>