Carregando...

Atributos de input HTML

Além de type, inputs aceitam atributos de regras e dicas: required, placeholder, intervalos, etc.

Resposta direta

Comuns: name, id, value, placeholder, required, min, max, step, maxlength, pattern, disabled, readonly. Orientam o usuário — valide no servidor depois.

📊 Atributos úteis de input

Attribute Role
placeholder Hint text inside an empty field
required Field must be filled before submit
min / max / step Limits for number/date-like types
maxlength Max characters for text-like types
pattern Regex-like allowed pattern
disabled Control not usable / not submitted
readonly Visible but not editable

Attributes on inputs

html
HTML Code
<label for="age">Age</label>
<input id="age" name="age" type="number" min="1" max="120" required>

<label for="code">Code</label>
<input id="code" name="code" type="text" maxlength="6" placeholder="ABC123" pattern="[A-Za-z0-9]{6}">

Experimente

  1. email required com placeholder
  2. number com min/max
  3. Enviar vazio — mensagem
  4. maxlength em código curto

Erros comuns

  • Só checks do navegador
  • disabled em campos que devem enviar
  • pattern complexo demais

Resumo

  • Atributos refinam comportamento
  • required, intervalos, maxlength
  • placeholder é dica
  • Label em cada campo

🧠 Teste Seu Conhecimento

Pronto para Começar

Teste Seu Conhecimento

Desafie-se com este questionário interativo e veja o quão bem você entende o tópico

❓
5
Perguntas
🎯
70%
Para Passar
♾️
∞
Tempo
🔄
∞
Tentativas

📝 Instruções

  • Leia cada pergunta cuidadosamente
  • Selecione a melhor resposta para cada pergunta
  • Você pode refazer o quiz quantas vezes quiser
  • Seu progresso será mostrado no topo