HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<div class="container">
<div class="card col-lg-8">
<civ class="card-body">
<h5><div class="card-header">My tricked out form
<div class="alert alert-success alert-dismissible fade show" role="alert" id="success_message" style="display:none; ">
<h3>Great!</h3> Form has been submitted successfully. You may now enter the site.
<button id="successalert" type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
<div class="alert alert-warning alert-dismissible fade show" role="alert" id="error_message" style="display:none; ">
<h3>Error!</h3> You have missing responses.
<button id="warningalert" type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>
</div>
</div></h5>
<form class="needs-validation" novalidate>
<div class="form-row">
<div class="col-md-4 mb-3">
<label for="validationTooltip01">First name</label>
<input type="text" class="form-control" id="validationTooltip01" placeholder="First name" value="Mark" required>
<div class="valid-feedback">
Looks good!
</div>
<div class="invalid-feedback">
Please enter your name.
</div>
</div>
<div class="col-md-4 mb-3">
<label for="validationTooltip02">Last name</label>
<input type="text" class="form-control" id="validationTooltip02" placeholder="Last name" value="Otto" required>
<div class="valid-feedback">
Looks good!
</div>
<div class="invalid-feedback">
Please enter your last name.
</div>
</div>
<div class="col-md-4 mb-3">
<label for="validationTooltipUsername">Username</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text" id="validationTooltipUsernamePrepend">@</span>
</div>
<input type="text" class="form-control" id="validationTooltipUsername" placeholder="Username" aria-describedby="validationTooltipUsernamePrepend" required>
<div class="valid-feedback">
Looks good!
</div>
<div class="invalid-feedback">
Please choose a unique and valid username.
</div>
</div>
</div>
</div>
<div class="form-row">
<div class="col-md-6 mb-3">
<label for="validationTooltip03">City</label>
<input type="text" class="form-control" id="validationTooltip03" placeholder="City" required>
<div class="valid-feedback">
Looks good!
</div>
<div class="invalid-feedback">
Please provide a valid city.
</div>
</div>
<div class="col-md-3 mb-3">
<label for="validationTooltip04">State</label>
<input type="text" class="form-control" id="validationTooltip04" placeholder="State" required>
<div class="valid-feedback">
Looks good!
</div>
<div class="invalid-feedback">
Please provide a valid state.
</div>
</div>
<div class="col-md-3 mb-3">
<label for="validationTooltip05">Zip</label>
<input type="text" class="form-control" id="validationTooltip05" placeholder="Zip" required>
<div class="valid-feedback">
Looks good!
</div>
<div class="invalid-feedback">
Please provide a valid zip.
</div>
</div>
</div>
<div class="form-group formbtns">
<div class="form-check form-check-inline">
<apan id="tandppop" class="d-inline-block" data-toggle="popover" data-placement="auto" title="Hold on slick" data-content="You have to read the Terms and Privacy before you can check the box. Yes. It's required">
<input name="tcheck" class="form-check-input" type="checkbox" value="" style="pointer-events: none;"id="invalidCheck" disabled required >
<label class="form-check-label" for="invalidCheck">
<button id="tandpbtn" type="button" class="btn btn-sm btn-primary" data-toggle="modal" data-target="#tandpmodal">Agree to terms and privacy</button>
</label>
<div class="invalid-feedback">
You must agree before submitting.
</div>
</div>
</div>
</apan>
<div class="card-footer">
<button class="btn btn-primary" type="submit">Submit form</button>
<span id="sitebtntip" class="d-inline-block" tabindex="0" data-toggle="tooltip" title="Form must be valid first">
<a id="sitebtn" class="btn btn-primary disabled" href="#" role="button" aria-disabled="true" style="pointer-events: none;">Enter Site</a></span>
</div>
</form>
</div>
</div>
</div>
<div id="tandpmodal" class="modal fade bd-example-modal-lg" tabindex="-1" role="dialog" aria-labelledby="tandpmodal" aria-hidden="true">
<div class="modal-dialog modal-lg" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Terms and Privacy</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div id="accordion">
<div class="card">
<div class="card-header" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Terms and Conditions
</button>
</h5>
</div>
<div id="collapseOne" class="collapse show" aria-labelledby="headingOne" data-parent="#accordion">
<div class="card-body">
<ul class="list-group">
<li class="list-group-item">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
<li class="list-group-item">Morbi leo risus</li>
<li class="list-group-item">Porta ac consectetur ac</li>
<li class="list-group-item">Vestibulum at eros</li>
</ul>
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingTwo">
<h5 class="mb-0">
<button class="btn btn-link collapsed" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
Privacy Policy
</button>
</h5>
</div>
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordion">
<div class="card-body">
<ul class="list-group">
<li class="list-group-item">Cras justo odio</li>
<li class="list-group-item">Dapibus ac facilisis in</li>
<li class="list-group-item">Morbi leo risus</li>
<li class="list-group-item">Porta ac consectetur ac</li>
<li class="list-group-item">Vestibulum at eros</li>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
body {background-color: #B0BEC5;}
.container {
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
min-height: 100vh;
}
ul li.list-group-item {
list-style: decimal inside;
display: list-item;
}
.form-control {
background-color: #f5f5f5;
}
.form-control:focus {
background-color: #ffffff;
}
.right {
float: right;
}
.formbtns {
display: flex;
justify-content: space-around;
}
.popover {
background-color: #f8f9fa;
}
.popover-header {
color: #856404;
background-color: #fff3cd;
border-color: #ffeeba;
}
.card-footer {
display: flex;
justify-content: space-between;
}
// Example starter JavaScript for disabling form submissions if there are invalid fields
(function() {
'use strict';
window.addEventListener('load', function() {
// Fetch all the forms we want to apply custom Bootstrap validation styles to
var forms = document.getElementsByClassName('needs-validation');
// Loop over them and prevent submission
var validation = Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(event) {
if (form.checkValidity() === false) {
$('#error_message').show();
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
if (form.checkValidity() === true) {
event.preventDefault();
event.stopPropagation();
$('#success_message').show();
$("#sitebtn").removeClass("disabled");
$("#sitebtn").css("pointer-events","auto");
request.doSubmit();
}
}, false);
});
}, false);
})();
$( "#tandpbtn" ).click(function() {
$("#invalidCheck").prop("disabled",false);
$('#tandppop').popover('dispose');
$("#invalidCheck").css("pointer-events","auto"); $("#sitebtntip").tooltip('dispose');
});
//Using localstorage to remember checkbox value
$(function() {
var data = localStorage.getItem("tcheck");
if (data !== null) {
$("input[name='tcheck']").attr("checked", "checked"); $("#invalidCheck").prop("disabled",false);
$('#tandppop').popover('dispose');
$("#invalidCheck").css("pointer-events","auto");
}
});
$("input[name='tcheck']").click(function() {
if ($(this).is(":checked")) {
localStorage.setItem("tcheck", $(this).val());
} else {
localStorage.removeItem("tcheck");
$("#invalidCheck").css("pointer-events","none"); $("#invalidCheck").prop("disabled",true);
$('#tandppop').popover('enable');
}
});
//initialize popover and tooltip
$(function () {
$('[data-toggle="popover"]').popover()
})
$(function () {
$('[data-toggle="tooltip"]').tooltip()
})
Also see: Tab Triggers