Back to CSS Input Fields URL with Protocol Pure CSS
Share
HTML
<label class="if-url">
  <span class="if-url-label">Website</span>
  <span class="if-url-wrap">
    <span class="if-url-prefix">https://</span>
    <input
      type="text"
      name="url-host"
      inputmode="url"
      placeholder="codefronts.com"
      pattern="[a-zA-Z0-9.-]+\\\\.[a-zA-Z]{2,}.*"
    />
  </span>
</label>
CSS
.if-url {
  display: grid;
  gap: 6px;
  width: 100%;
  max-width: 320px;
}

.if-url-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: #b8b6d4;
  text-transform: uppercase;
}

.if-url-wrap {
  display: inline-flex;
  align-items: stretch;
  background: #1a1a22;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  overflow: hidden;
  transition: border-color 0.2s;
}

.if-url-wrap:focus-within {
  border-color: #06b6d4;
}

.if-url-prefix {
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  background: rgba(6, 182, 212, 0.08);
  color: #06b6d4;
  font:
    600 12px/1 "JetBrains Mono",
    monospace;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.if-url input {
  flex: 1;
  min-width: 0;
  padding: 12px 14px;
  border: 0;
  outline: none;
  background: transparent;
  color: #f0eeff;
  font:
    500 14px/1 system-ui,
    sans-serif;
}

.if-url input::placeholder {
  color: #b8b6d4;
}