A comprehensive guide to HTML (HyperText Markup Language) - the standard markup language for creating web pages, covering semantic elements, accessibility, forms, and modern HTML5 features.
HTML (HyperText Markup Language) is the standard markup language used to create web pages. It provides the structure and content of web documents through a system of elements and attributes, forming the foundation of all web development alongside CSS and JavaScript.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Color Converter Tool</title>
<meta name="description" content="Convert colors between RGB, HEX, HSL formats">
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/colors">Colors</a></li>
<li><a href="/image-converter">Image Converter</a></li>
</ul>
</nav>
</header>
<main>
<section>
<h1>Color Converter</h1>
<p>Convert colors between different formats</p>
</section>
</main>
<footer>
<p>© 2024 RGBmatic. All rights reserved.</p>
</footer>
</body>
</html><!-- Color picker application structure -->
<article class="color-tool">
<header>
<h2>RGB to HEX Converter</h2>
<p>Convert RGB color values to hexadecimal format</p>
</header>
<section class="input-section">
<h3>RGB Input</h3>
<form id="rgb-form">
<fieldset>
<legend>RGB Values</legend>
<label for="red">Red (0-255):</label>
<input type="number" id="red" name="red" min="0" max="255" value="255" required>
<label for="green">Green (0-255):</label>
<input type="number" id="green" name="green" min="0" max="255" value="0" required>
<label for="blue">Blue (0-255):</label>
<input type="number" id="blue" name="blue" min="0" max="255" value="0" required>
</fieldset>
<button type="submit">Convert to HEX</button>
</form>
</section>
<section class="output-section">
<h3>HEX Output</h3>
<output id="hex-output" for="rgb-form">#ff0000</output>
<div class="color-preview" style="background-color: #ff0000;" aria-label="Color preview"></div>
</section>
<aside class="color-info">
<h4>Color Information</h4>
<dl>
<dt>RGB:</dt>
<dd id="rgb-display">rgb(255, 0, 0)</dd>
<dt>HEX:</dt>
<dd id="hex-display">#ff0000</dd>
<dt>HSL:</dt>
<dd id="hsl-display">hsl(0, 100%, 50%)</dd>
</dl>
</aside>
</article><!-- Advanced color picker form -->
<form class="color-picker-form" method="post" action="/api/save-color">
<fieldset>
<legend>Color Selection</legend>
<!-- Color input (HTML5) -->
<label for="color-picker">Choose Color:</label>
<input type="color" id="color-picker" name="color" value="#ff0000">
<!-- Range inputs for RGB values -->
<label for="red-range">Red: <span id="red-value">255</span></label>
<input type="range" id="red-range" name="red" min="0" max="255" value="255">
<label for="green-range">Green: <span id="green-value">0</span></label>
<input type="range" id="green-range" name="green" min="0" max="255" value="0">
<label for="blue-range">Blue: <span id="blue-value">0</span></label>
<input type="range" id="blue-range" name="blue" min="0" max="255" value="0">
</fieldset>
<fieldset>
<legend>Color Format</legend>
<input type="radio" id="format-hex" name="format" value="hex" checked>
<label for="format-hex">HEX</label>
<input type="radio" id="format-rgb" name="format" value="rgb">
<label for="format-rgb">RGB</label>
<input type="radio" id="format-hsl" name="format" value="hsl">
<label for="format-hsl">HSL</label>
</fieldset>
<fieldset>
<legend>Save Options</legend>
<label for="color-name">Color Name:</label>
<input type="text" id="color-name" name="name" placeholder="My Custom Color">
<label for="color-tags">Tags:</label>
<input type="text" id="color-tags" name="tags" placeholder="red, vibrant, primary">
<input type="checkbox" id="make-public" name="public" value="true">
<label for="make-public">Make this color public</label>
</fieldset>
<button type="submit">Save Color</button>
<button type="reset">Reset Form</button>
</form><!-- Accessible color picker component -->
<div class="color-picker" role="application" aria-label="Color Picker Tool">
<h2 id="picker-title">Interactive Color Picker</h2>
<div class="color-canvas"
role="slider"
aria-labelledby="picker-title"
aria-valuemin="0"
aria-valuemax="360"
aria-valuenow="0"
aria-valuetext="Red color selected"
tabindex="0">
<div class="color-handle" aria-hidden="true"></div>
</div>
<div class="color-inputs" role="group" aria-label="Color value inputs">
<label for="hue-input">Hue:</label>
<input type="number" id="hue-input"
aria-describedby="hue-help"
min="0" max="360" value="0">
<div id="hue-help" class="help-text">Hue value from 0 to 360 degrees</div>
<label for="saturation-input">Saturation:</label>
<input type="number" id="saturation-input"
aria-describedby="saturation-help"
min="0" max="100" value="100">
<div id="saturation-help" class="help-text">Saturation percentage from 0 to 100</div>
</div>
<div class="color-result"
role="status"
aria-live="polite"
aria-label="Selected color result">
<div class="color-swatch" aria-hidden="true"></div>
<span class="color-value">#ff0000</span>
</div>
</div>
<!-- Skip navigation for accessibility -->
<a href="#main-content" class="skip-link">Skip to main content</a>
<!-- Accessible image with proper alt text -->
<figure>
<img src="color-wheel.jpg"
alt="Color wheel showing the relationship between primary, secondary, and tertiary colors"
loading="lazy">
<figcaption>
A traditional color wheel demonstrating color relationships and harmony
</figcaption>
</figure><!-- Canvas-based image color extractor -->
<section class="image-color-extractor">
<h3>Extract Colors from Image</h3>
<div class="upload-area">
<input type="file" id="image-upload" accept="image/*" hidden>
<label for="image-upload" class="upload-button">
<svg aria-hidden="true">
<use href="#upload-icon"></use>
</svg>
Choose Image
</label>
</div>
<canvas id="image-canvas" width="400" height="300" style="display: none;">
Your browser does not support the canvas element.
</canvas>
<div class="extracted-colors" id="color-palette">
<!-- Colors will be populated by JavaScript -->
</div>
</section>
<!-- SVG icons -->
<svg style="display: none;">
<defs>
<symbol id="upload-icon" viewBox="0 0 24 24">
<path d="M14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18A2,2 0 0,0 20,20V8L14,2M18,20H6V4H13V9H18V20Z" />
</symbol>
<symbol id="copy-icon" viewBox="0 0 24 24">
<path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z" />
</symbol>
</defs>
</svg><!-- Custom color picker web component -->
<script>
class ColorPicker extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
}
connectedCallback() {
this.render();
this.setupEventListeners();
}
render() {
this.shadowRoot.innerHTML = `
<style>
:host {
display: block;
width: 300px;
padding: 1rem;
border: 1px solid #ccc;
border-radius: 8px;
}
.color-display {
width: 100%;
height: 100px;
border: 1px solid #ddd;
margin-bottom: 1rem;
}
.controls {
display: grid;
gap: 0.5rem;
}
label {
display: flex;
justify-content: space-between;
align-items: center;
}
input[type="range"] {
flex: 1;
margin-left: 1rem;
}
</style>
<div class="color-display"></div>
<div class="controls">
<label>
Red: <span class="red-value">255</span>
<input type="range" class="red-slider" min="0" max="255" value="255">
</label>
<label>
Green: <span class="green-value">0</span>
<input type="range" class="green-slider" min="0" max="255" value="0">
</label>
<label>
Blue: <span class="blue-value">0</span>
<input type="range" class="blue-slider" min="0" max="255" value="0">
</label>
</div>
<div class="color-output">
<strong>HEX: <span class="hex-value">#ff0000</span></strong>
</div>
`;
}
setupEventListeners() {
const sliders = this.shadowRoot.querySelectorAll('input[type="range"]');
sliders.forEach(slider => {
slider.addEventListener('input', () => this.updateColor());
});
}
updateColor() {
const r = this.shadowRoot.querySelector('.red-slider').value;
const g = this.shadowRoot.querySelector('.green-slider').value;
const b = this.shadowRoot.querySelector('.blue-slider').value;
const hex = this.rgbToHex(r, g, b);
const rgb = `rgb(${r}, ${g}, ${b})`;
this.shadowRoot.querySelector('.color-display').style.backgroundColor = rgb;
this.shadowRoot.querySelector('.red-value').textContent = r;
this.shadowRoot.querySelector('.green-value').textContent = g;
this.shadowRoot.querySelector('.blue-value').textContent = b;
this.shadowRoot.querySelector('.hex-value').textContent = hex;
// Dispatch custom event
this.dispatchEvent(new CustomEvent('colorchange', {
detail: { r, g, b, hex, rgb }
}));
}
rgbToHex(r, g, b) {
return `#${((1 << 24) + (parseInt(r) << 16) + (parseInt(g) << 8) + parseInt(b)).toString(16).slice(1)}`;
}
}
customElements.define('color-picker', ColorPicker);
</script>
<!-- Usage -->
<color-picker id="my-picker"></color-picker>
<script>
document.getElementById('my-picker').addEventListener('colorchange', (event) => {
console.log('Color changed:', event.detail);
});
</script><!-- SEO-optimized head section -->
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- Primary Meta Tags -->
<title>RGB to HEX Color Converter | Free Online Tool</title>
<meta name="title" content="RGB to HEX Color Converter | Free Online Tool">
<meta name="description" content="Convert RGB color values to HEX format instantly. Free online color converter tool with live preview and copy functionality.">
<meta name="keywords" content="RGB to HEX, color converter, hex color, rgb color, color tool">
<!-- Open Graph / Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="https://rgbmatic.com/rgb-to-hex">
<meta property="og:title" content="RGB to HEX Color Converter | Free Online Tool">
<meta property="og:description" content="Convert RGB color values to HEX format instantly. Free online color converter tool with live preview and copy functionality.">
<meta property="og:image" content="https://rgbmatic.com/images/rgb-to-hex-preview.jpg">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="https://rgbmatic.com/rgb-to-hex">
<meta property="twitter:title" content="RGB to HEX Color Converter | Free Online Tool">
<meta property="twitter:description" content="Convert RGB color values to HEX format instantly. Free online color converter tool with live preview and copy functionality.">
<meta property="twitter:image" content="https://rgbmatic.com/images/rgb-to-hex-preview.jpg">
<!-- Canonical URL -->
<link rel="canonical" href="https://rgbmatic.com/rgb-to-hex">
<!-- Structured Data -->
<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "WebApplication",
"name": "RGB to HEX Color Converter",
"description": "Convert RGB color values to HEX format instantly",
"url": "https://rgbmatic.com/rgb-to-hex",
"applicationCategory": "DesignApplication",
"operatingSystem": "Any",
"offers": {
"@type": "Offer",
"price": "0",
"priceCurrency": "USD"
}
}
</script>
</head><!-- Optimized resource loading -->
<head>
<!-- Preload critical resources -->
<link rel="preload" href="/fonts/main-font.woff2" as="font" type="font/woff2" crossorigin>
<link rel="preload" href="/css/critical.css" as="style">
<link rel="preload" href="/js/app.js" as="script">
<!-- Critical CSS inline -->
<style>
/* Critical above-the-fold styles */
body { font-family: system-ui, sans-serif; margin: 0; }
.header { background: #fff; padding: 1rem; }
</style>
<!-- Non-critical CSS with media query -->
<link rel="stylesheet" href="/css/main.css" media="print" onload="this.media='all'">
<noscript><link rel="stylesheet" href="/css/main.css"></noscript>
</head>
<body>
<!-- Lazy loaded images -->
<img src="placeholder.jpg"
data-src="actual-image.jpg"
alt="Color palette example"
loading="lazy"
decoding="async">
<!-- Responsive images -->
<picture>
<source media="(min-width: 800px)" srcset="large-image.webp" type="image/webp">
<source media="(min-width: 800px)" srcset="large-image.jpg">
<source srcset="small-image.webp" type="image/webp">
<img src="small-image.jpg" alt="Responsive color chart" loading="lazy">
</picture>
<!-- Deferred JavaScript -->
<script src="/js/critical.js"></script>
<script src="/js/non-critical.js" defer></script>
</body>Explore these comprehensive pillar articles related to HTML
A comprehensive guide to color theory, its fundamental principles, and practical applications in digital design and web development.
A comprehensive guide to monochromatic color schemes - sophisticated single-hue harmonies that create unified visual experiences through systematic variations in saturation, lightness, and tonal relationships, essential for elegant design compositions, brand consistency, and advanced color theory applications requiring cohesive aesthetic unity.
Comprehensive guide to complementary colors - opposing hues on the color wheel that create maximum visual contrast, dynamic tension, and powerful design impact through scientific color relationships and perceptual phenomena.
Comprehensive guide to analogous color schemes - adjacent hues on the color wheel that create natural harmony, visual cohesion, and sophisticated design solutions through subtle color relationships and graduated transitions.
Discover more about HTML and related color theory concepts
A comprehensive guide to color theory, its fundamental principles, and practical applications in digital design and web development.
A comprehensive guide to monochromatic color schemes - sophisticated single-hue harmonies that create unified visual experiences through systematic variations in saturation, lightness, and tonal relationships, essential for elegant design compositions, brand consistency, and advanced color theory applications requiring cohesive aesthetic unity.
Comprehensive guide to analogous color schemes - adjacent hues on the color wheel that create natural harmony, visual cohesion, and sophisticated design solutions through subtle color relationships and graduated transitions.
Comprehensive guide to complementary colors - opposing hues on the color wheel that create maximum visual contrast, dynamic tension, and powerful design impact through scientific color relationships and perceptual phenomena.
A comprehensive guide to split-complementary color schemes - sophisticated three-color harmonies that combine a base color with two colors adjacent to its complement, creating balanced visual contrast with reduced tension compared to direct complementary pairs, essential for refined design compositions, brand identity systems, and advanced color theory applications.
A comprehensive guide to tetradic color schemes - sophisticated four-color harmonies that use two complementary pairs arranged in rectangular or square formations on the color wheel, providing maximum color variety while maintaining structured relationships essential for dynamic design compositions, brand systems, and advanced color theory applications.
Discover more color terminology and concepts in our comprehensive glossary.
Browse Full Glossary