HTML Timer

HTML Timer

 HTML ,CSS AND JAVA SCRIPT TIMER


Today we are going to make a website that measures time 
These are for your birthdays or special days 
Time can be measured...

HTML CODE:-

<div class="container">
  <link rel="stylesheet" type="text/css" href="style.css"
  <h1 id="headline">Countdown to O/L Exam</h1>
  <div id="countdown">
    <ul>
      <li><span id="days"></span>days</li>
      <li><span id="hours"></span>Hours</li>
      <li><span id="minutes"></span>Minutes</li>
      <li><span id="seconds"></span>Seconds</li>
    </ul>
  </div>
  <div id="content" class="emoji">
    <span>🥳</span>
    <span>🎉</span>
    <span>🎂</span>
  </div>
</div>


INDEX.JS 

 // Import stylesheets
import './style.scss';
(function () {
  const second = 1000,
    minute = second * 60,
    hour = minute * 60,
    day = hour * 24;
  //I'm adding this section so I don't have to keep updating this pen every year :-)
  //remove this if you don't need it
  let today = new Date(),
    dd = String(today.getDate()).padStart(2, '0'),
    mm = String(today.getMonth() + 1).padStart(2, '0'),
    yyyy = today.getFullYear(),
    nextYear = yyyy + 1,
    dayMonth = '05/01/',
    birthday = dayMonth + yyyy;
  today = mm + '/' + dd + '/' + yyyy;
  if (today > birthday) {
    birthday = dayMonth + nextYear;
  }
  //end
  const countDown = new Date(birthday).getTime(),
    x = setInterval(function () {
      const now = new Date().getTime(),
        distance = countDown - now;
      (document.getElementById('days').innerText = Math.floor(distance / day)),
        (document.getElementById('hours').innerText = Math.floor(
          (distance % day) / hour
        )),
        (document.getElementById('minutes').innerText = Math.floor(
          (distance % hour) / minute
        )),
        (document.getElementById('seconds').innerText = Math.floor(
          (distance % minute) / second
        ));
      //do something later when date is reached
      if (distance < 0) {
        document.getElementById('headline').innerText = "It's my birthday!";
        document.getElementById('countdown').style.display = 'none';
        document.getElementById('content').style.display = 'block';
        clearInterval(x);
      }
      //seconds
    }, 0);
})();


PACKGE.json


{
  "name": "pure-css-app",
  "version": "0.0.0",
  "private": true,
  "dependencies": {}
}



STYLE.CSS

/* general styling */  
:root {  
    --smaller: .75;  
   }  
   * {  
    box-sizing: border-box;  
    margin: 0;  
    padding: 0;  
   }  
   html, body {  
    height: 100%;  
    margin: 0;  
   }  
   body {  
    align-items: center;  
    background-color: #ffd54f;  
    display: flex;  
    font-family: -apple-system,  
     BlinkMacSystemFont,  
     "Segoe UI",  
     Roboto,  
     Oxygen-Sans,  
     Ubuntu,  
     Cantarell,  
     "Helvetica Neue",  
     sans-serif;  
   }  
   .container {  
    color: #333;  
    margin: 0 auto;  
    text-align: center;  
   }  
   h1 {  
    font-weight: normal;  
    letter-spacing: .125rem;  
    text-transform: uppercase;  
   }  
   li {  
    display: inline-block;  
    font-size: 1.5em;  
    list-style-type: none;  
    padding: 1em;  
    text-transform: uppercase;  
   }  
   li span {  
    display: block;  
    font-size: 4.5rem;  
   }  
   .emoji {  
    display: none;  
    padding: 1rem;  
   }  
   .emoji span {  
    font-size: 4rem;  
    padding: 0 .5rem;  
   }  
   @media all and (max-width: 768px) {  
    h1 {  
     font-size: calc(1.5rem * var(--smaller));  
    }  
    li {  
     font-size: calc(1.125rem * var(--smaller));  
    }  
    li span {  
     font-size: calc(3.375rem * var(--smaller));  
    }  
   }  




TML (HyperText Markup Language) is the most basic building block of the Web. It defines the meaning and structure of web content. Other technologies besides HTML are generally used to describe a web page's appearance/presentation (CSS) or functionality/behavior (JavaScript).

"Hypertext" refers to links that connect web pages to one another, either within a single website or between websites. Links are a fundamental aspect of the Web. By uploading content to the Internet and linking it to pages created by other people, you become an active participant in the World Wide Web.

HTML uses "markup" to annotate text, images, and other content for display in a Web browser. HTML markup includes special "elements" such as <head><title><body><header><footer><article><section><p><div><span><img><aside><audio><canvas><datalist><details><embed><nav><search><output><progress><video><ul><ol><li> and many others.

An HTML element is set off from other text in a document by "tags", which consist of the element name surrounded by "<" and ">". The name of an element inside a tag is case-insensitive. That is, it can be written in uppercase, lowercase, or a mixture. For example, the <title> tag can be written as <Title><TITLE>, or in any other way. However, the convention and recommended practice is to write tags in lowercase.

The articles below can help you learn more about HTML.

Key resources

HTML Introduction

If you're new to web development, be sure to read our HTML Basics article to learn what HTML is and how to use it.

HTML Tutorials

For articles about how to use HTML, as well as tutorials and complete examples, check out our HTML Learning Area.

HTML Reference

In our extensive HTML reference section, you'll find the details about every element and attribute in HTML.

Beginner's tutorials

Our HTML Learning Area features multiple modules that teach HTML from the ground up — no previous knowledge required.

Introduction to HTML

This module sets the stage, getting you used to important concepts and syntax such as looking at applying HTML to text, how to create hyperlinks, and how to use HTML to structure a web page.

Multimedia and embedding

This module explores how to use HTML to include multimedia in your web pages, including the different ways that images can be included, and how to embed video, audio, and even entire other webpages.

HTML tables

Representing tabular data on a webpage in an understandable, accessible way can be a challenge. This module covers basic table markup, along with more complex features such as implementing captions and summaries.

HTML forms

Forms are a very important part of the Web — these provide much of the functionality you need for interacting with websites, e.g. registering and logging in, sending feedback, buying products, and more. This module gets you started with creating the client-side/front-end parts of forms.

Use HTML to solve common problems

Provides links to sections of content explaining how to use HTML to solve very common problems when creating a web page: dealing with titles, adding images or videos, emphasizing content, creating a basic form, etc.

Advanced topics

CORS enabled image

The crossorigin attribute, in combination with an appropriate CORS header, allows images defined by the <img> element to be loaded from foreign origins and used in a <canvas> element as if they were being loaded from the current origin.

CORS settings attributes

Some HTML elements that provide support for CORS, such as <img> or <video>, have a crossorigin attribute (crossOrigin property), which lets you configure the CORS requests for the element's fetched data.

Preloading content with rel="preload"

The preload value of the <link> element's rel attribute allows you to write declarative fetch requests in your HTML <head>, specifying resources that your pages will need very soon after loading, which you therefore want to start preloading early in the lifecycle of a page load, before the browser's main rendering machinery kicks in. This ensures that they are made available earlier and are less likely to block the page's first render, leading to performance improvements. This article provides a basic guide to how preload works.

Reference

HTML reference

HTML consists of elements, each of which may be modified by some number of attributes. HTML documents are connected to each other with links.

HTML element reference

Browse a list of all HTML elements.

HTML attribute reference

Elements in HTML have attributes. These are additional values that configure the elements or adjust their behavior in various ways.

Global attributes

Global attributes may be specified on all HTML elementseven those not specified in the standard. This means that any non-standard elements must still permit these attributes, even though those elements make the document HTML5-noncompliant.

Inline-level elements and block-level elements

HTML elements are usually "inline-level" or "block-level" elements. An inline-level element occupies only the space bounded by the tags that define it. A block-level element occupies the entire space of its parent element (container), thereby creating a "block box".

HTML comments

HTML comments are used to add explanatory notes to the markup or to prevent the browser from interpreting specific parts of the document.

Guide to media types and formats on the web

The <audio> and <video> elements allow you to play audio and video media natively within your content without the need for external software support.

HTML content categories

HTML is comprised of several kinds of content, each of which is allowed to be used in certain contexts and is disallowed in others. Similarly, each context has a set of other content categories it can contain and elements that can or can't be used in them. This is a guide to these categories.

Quirks mode and standards mode

Historical information on quirks mode and standards mode.

Applying color to HTML elements using CSS

This article covers most of the ways you use CSS to add color to HTML content, listing what parts of HTML documents can be colored and what CSS properties to use when doing so.







































Post a Comment

Previous Post Next Post