HTML code script for a Color converter

Created on 3 July, 2024 • 117 views • 1 minutes read

HTML code script for a Color converter

<!DOCTYPE html>

<html lang="en">

<head>

  <meta charset="UTF-8">

  <meta name="viewport" content="width=device-width, initial-scale=1.0">

  <title>Color Converter</title>

  <style>

    /* Add some styles for the layout (optional) */

  </style>

</head>

<body>

  <h1>Color Converter</h1>

  <div id="converter">

    <label for="colorInput">Enter a color value:</label>

    <input type="text" id="colorInput" placeholder="Hex (#fff), RGB (255,0,0), or color name (red)">

    <div id="output">

      <p>Converted Values:</p>

      <ul>

        <li>Hex: <span id="hexOutput"></span></li>

        <li>RGB: <span id="rgbOutput"></span></li>

      </ul>

    </div>

    <button onclick="convertColor()">Convert</button>

  </div>

  <script src="script.js"></script>

</body>

</html>