<a href="#modalDialog" class="modalBtn" id="modalTrigger">Click me to open</a>

<dialog class="modal" id="modalDialog" tabindex="-1">
    <a href="#modalTrigger" class="close" aria-label="Close dialog">&times;</a>
    <p>Hello Beautiful!</p>
// styling to center the modal
.modal {  
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
  p {
    font-size: 1.5em

.modal > div {
  background: wheat;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  padding: 1em;
  position: relative;
  width: 50%;

// modal fades in when focused.
// note this is not a real-world solution
.modal:target {
  opacity: 1;
  visibility: visible;

// Additional Styling

body {
  font-family: monospace;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;

a.modalBtn {
  flex: 1;
  background-color: #c69;
  border: none;
  padding: 1.5em;
  max-width: 30%;
  color: white;
  transition-duration: .25s;
  text-align: center;
  text-decoration: none;
  font-size: 1.25em;
  &:focus {
    background-color: darken(#c69, 20%)

.close {
  background-color: transparent;
  position: absolute;
  top: .2em;
  right: .5em;
  font-size: 1.5em;
  cursor: pointer;
  text-decoration: none;
  &:focus {
    color: #c69
View Compiled

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

  1. https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js