<section>
  <h2>Inscrivez-vous à notre newsletter</h2>
<div class="form-container">
   <div class="email-container">
    <label for="abo-newsletterSubscriber" class="sr-only">Votre adresse email (exemple : prenom.nom@mail.fr)</label>
    <input id="abo-newsletterSubscriber" type="email" name="email" autocomplete="email">
  </div>
</div>
</section>
section { 
  width: 30rem;
  height: auto;
  padding: 1.5%;
  box-sizing: border-box;
}

.form-container  {
  padding: 2% 0;
}
.email-container {
  position: relative;
  }

label,
input {
  display: block;
}

label {
  margin-bottom: 0.3rem;
}

.sr-only {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	border: 0;
	white-space: nowrap;
	overflow: hidden;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
}

.email-container:focus-within label {
  top: -1.5rem;
	width: auto;
	height: auto;
	white-space: normal;
	overflow: visible;
	z-index: 100;
	clip: auto;
	clip-path: none;
	}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.