Skip to content
Coding India Lab
  • PDF Tools
    JPG to PDF

    JPG to PDF

    PNG to PDF

    PNG to PDF

    WEBP to PDF

    WEBP to PDF

    Protect PDF File

    Protect PDF File

  • Category

    SVG Converter

    • PNG to SVG
    • JPG to SVG
    • WEBP to SVG
    • AVIF to SVG

    SEO Tool

    • HTML Heading Checker
    • Word Counter
    • Keyword Density Checker
    • Internal Link Checker
    • Meta Tags Analyzer
    • Meta Tags Generator

    Excel Converter

    • Excel to XML
    • Excel to HTML
    • Excel to JSON
    • JSON to Excel

    Social Downloader

    • Instagram Reel
    • Facebook Reel
    • Facebook Video
    • YouTube Thumbnail
    • Vimeo Thumbnail

    Text Converter

    • Lower Case To Upper Case
    • Remove Duplicate Words
    • Auto Capitalize Sentences
    • Online Text Editor

    Colors Converter

    • Hex To Pantone
    • RGB To Pantone
    • RGB to HEX
    • CSS Gradient Generator

    WEBP Converter

    • JPG To WEBP
    • PNG To WEBP
    • WEBP To JPG
    • WEBP To PNG

    Minify Generator

    • CSS Minify
    • HTML Minify
    • JS Minify
  • Calculator Tools
    • Cubic Feet
    • Volumetric weight
    • KG to Pound
    • Length unit converter
  • Pages
    • About Us
    • Privacy and Policy
    • Terms and Conditions
    • Disclaimer
    • Contact Us
  • Blog
How to create Word and Character Counter using HTML CSS and JavaScript

How to create Word Counter using HTML CSS and JavaScript

admin, July 26, 2024February 22, 2025

Word and Character Counter using HTML CSS and JavaScript Full Details

You can learn to create Word and Character counter using HTML CSS and JavaScript. We are providing complete guide here which will explain all the steps step by step and you can create it by following it.
Word, Character, Sentence and Paragraph Counter is an application which counts the words and characters in textarea. It is designed using HTML, CSS and JavaScript. User can type text in text area and Word Counter will show the number of words and characters typed by them.

Project Details

  • Project Introduction
  • HTML Code
  • CSS Code
  • JavaScript Code
  • Preview

Project Introduction

To make this you will need the following:
  • Basic knowledge of HTML, CSS, and JavaScript.
  • A code  editor (e.g.,Notpad++, Subline, Visual Studio Code).
  • Web browser for testing.

HTML Details

To start you need to create an HTML structure for the word counter. Go to your local system, open an editor and create a file in HTML. Use a simple form in the text area and add an element to count the paragraphs.
How to do it:
  • Open your code editor.
  • Create an HTML file.
  • Design a form with a textarea for user input.
  • Add an element (e.g., a <div>) to display the word and character count.
  • Link your CSS and JavaScript files.

 HTML Code:

<!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>Document</title>
<link href=”https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap” rel=”stylesheet”>
<link rel=”stylesheet” href=”styles.css” />
</head>
<body>

<h1>Word Counter</h1>
<div class=”container”>
<textarea placeholder=”Enter your text here…”></textarea>
<div class=”output-container”>
<div class=”output”>
<p class=”words”>Words</p>
<span data-word-count>0</span>
</div>
<div class=”output”>
<p class=”characters”>Characters</p>
<span data-character-count>0</span>
</div>
<div class=”output”>
<p class=”sentences”>Sentences</p>
<span data-sentence-count>0</span>
</div>
<div class=”output”>
<p class=”paragraphs”>Paragraphs</p>
<span data-paragraph-count>0</span>
</div>
</div>
</div>
<script src=”script.js” defer></script>
</body>
</html>

CSS Code:

    <style>
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: Poppins;
  background-color: #ffbf47;
  color: #a09fa4;
  height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5rem;
}
.container {
  width: 100%;
  max-width: 46rem;
  background-color: white;
  border-radius: 0.5rem;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
textarea {
  resize: none;
  width: 100%;
  height: 250px;
  padding: 1rem;
  color: #242e3e;
  font: inherit;
  font-size: 1rem;
  border-radius: inherit;
  outline: none;
  border: 0;
}
.output-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3.5rem;
  padding: 1rem;
  border-top: 1px solid gray;
}
.output {
  display: flex;
  flex-direction: column;
  text-align: center;
}
.output p {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.output span {
  font-size: 1.6rem;
  font-weight: 700;
  color: #242e3e;
}
h1 {
    font-size: 2.6rem;
    color: #000;
    text-align: center;
    width: 100%;
    margin: 0 auto;
    padding: 0 20px;
}
</style>

JavaScript Code

<script>
const input = document.querySelector(“textarea”);
const wordCount = document.querySelector(“[data-word-count]”);
const characterCount = document.querySelector(“[data-character-count]”);
const sentenceCount = document.querySelector(“[data-sentence-count]”);
const paragraphCount = document.querySelector(“[data-paragraph-count]”);
input.addEventListener(“input”, function () {
  if (input.value) {
    // Count Words
    const wordsArray = input.value.split(” “).filter((word) => word !== “”);
    wordCount.innerText = wordsArray.length;
    // Count Characters
    characterCount.innerText = input.value.length;
    // Count Sentences
    const sentenceArray = input.value.split(/[.!]/);
    sentenceCount.innerText = sentenceArray.length – 1;
    // Count Paragraph
    const paragraphArray = input.value
      .split(“\n”)
      .filter((p) => p.trim() !== “”);
    paragraphCount.innerText = paragraphArray.length;
  } else {
    wordCount.innerText =
      characterCount.innerText =
      sentenceCount.innerText =
      paragraphCount.innerText =
        0;
  }
});
</script>

Preview

html jquery

Post navigation

Previous post
Next post

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts

  • How Do I Copy Text from an Image?
  • How do you merge two PDF documents into one?
  • How to Bulk Convert Images to WebP For Free?
  • How to create a QR code for free?
  • How to Calculate Interest Rate Per Month?
  • Convert HTML Table To JPG Image Using Javascript
  • Convert Images Into WEBP Free Unlimited
  • Convert JPG Image To WEBP Format Using PHP Mysqli JQuery
  • Create GIF Images Using HTML JQuery
  • Resize Your Images Online Unlimited
  • How To Change PNG To WEBP Using PHP JQuery
  • Image To Video Converter Using HTML JQuery

Categories

  • birthday wishes
  • html
  • jquery
  • php
  • seo
  • social
  • tools
  • WordPress

Social Tools

  • Facebook Reel Downloader
  • Facebook Video Downloader
  • YouTube Thumbnail Downloader
  • Vimeo Thumbnail Downloader

Image Converter

  • Bulk JPEG To WEBP
  • Bulk JPG to WEBP
  • Bulk PNG to WEBP
  • Bulk WEBP to PNG
  • Bulk WEBP Converter

Text Converter

  • Character counter
  • Remove Duplicate Words
  • Word Counter
  • Small Text Generator
  • Reverse Text Generator

PDF Tools

  • JPG to PDF
  • PNG to PDF
  • WEBP to PDF
  • Protect PDF file
©2025 Blog | WordPress Theme by SuperbThemes

Copyright © 2025 Coding India Lab. All rights reserved.