css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

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.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

  <div id='page' class='container'>
    <div id="form" class="container">
     Search Wikipedia <form>
          <input id='search' class="input ">
        <div id="btn" ><a class='text1'href=#><img src='https://lh3.googleusercontent.com/MxGCgTdCBdG8lw6U8aZFWLetjenp5uFp9t3QyMM-jUWtLC4UzDwdTKP2IZnsqTqUm7fDLBvd2v3DwiRAdMe57a9hfEP-b0Bk2c5z7Zi8raILfLt4yWo2v7nPwpITrQRqOdELrlF6Rg=s24-p-k' /></a></div>
        <div id="randombtn" ><a class="text" href=#><img src='https://lh3.googleusercontent.com/dagf-ARNa-8cHmiQ9k0VZDcSQ5ikfCU1HdCayMQHSeGdbhw3zN7cMfB016Vpe1w6G3gTh96lhdgdCj1JKvj9mqRjPv0Bv83Vj3MfYEEUXbtgQfQrBhFyaV-7iInfiCVvZpvlBNwNlw=s24-p-k' /></a></div>

    <div id="results" class="">
      <img class='closebutton' src='https://lh3.googleusercontent.com/MUi_08PPx460SNTCqJUPXg94Vu9HfkA9fyM3umUZM17_yZISjaDEfs-kd1xCy7iUwL4IepOqAFwk8VBI4aUZDXJTG2N7rC9rGJPfeGBXuiGqmcy3KmA84KG7rY9sHrV_QleOGTy0CA=s50-p-k'></img>
      <div id="addedResults">


              #page {
  height: 100%;
  width: 100%;
  background-color: white;

#search {
  margin-left: 22px;
  border-radius: ;
  border-style: none;
  text-align: center;
  height: 50px;
  width: 200px;
  flex-grow: 2;
  outline: none;

form {
  border: solid;
  display: flex;
  flex-direction: row;
  border-radius: 50px;
  box-shadow: 0 0 6px black;

#form {
  margin: ;
  width: 400px;
  padding-top: 200px;
  position: relative;

#btn {
  width: 40px;
  height: 50px;
  background-color: #494949;
  color: white;

#randombtn {
  width: 40px;
  height: 50px;
  background-color: #ec7063;
  border-top-right-radius: 50px;
  border-bottom-right-radius: 50px;
  color: white;

.text {
  position: absolute;
  margin-top: 12px;
  margin-left: 5px;

.text1 {
  position: absolute;
  margin-top: 14px;
  margin-left: 7px;

.input {
  display: inline-block;
  height: 100%;

.block {
  padding: 30px;
  margin: 7px;
  cursor: pointer;
  height: 185px;
  padding-left: 30px;
  border-left: 10px solid #4c4b4b;
  border-right: 10px solid #4c4b4b;
  border-radius: 5px;
  border-top: 2px solid #4c4b4b;
  border-bottom: 2px solid #4c4b4b;

#results {
  display: none;
  padding: 3px;
  background-color: white;
  border: solid;
  border-width: 5px;
  border-radius: 10px;
  border-color: black;
.closebutton {
  width: 50px;
  height: 50px;
  padding-bottom: 5px;
  margin: 20px;
  margin-left: 95%;
  margin-top: 1%;
  cursor: pointer;

#addedresults {
  margin-top: 30px;

              $(document).ready(function() {
  var searchTerm = "";
  var page = [];
  var wiki = "https://en.wikipedia.org/wiki/";
  var url = "";
  var urlLink = "";
  var wikiPage = [];

  //Hide once page is loaded

  //call JSON with the search term
  function ajax() {
    $.getJSON(url, function(data) {
      //get a list of the page ID's to use
      wikiPage = Array.from(data.query.pageids);

      //Iterate through the wiki data and if it contains the field add to the new block div, if not not continue to the next field
      for (var i = 0; i < 9; i++) {
          "<div class =' block' id = 'block" + i + "'" + ">" + "</div>" + "<br>"

        var result = "#block" + i;
        var text = "#" + result + "text";
        var image = "#" + result + "image";

          "<h1>" + data["query"]["pages"][wikiPage[i]]["title"] + "</h1>"

        if (data["query"]["pages"][wikiPage[i]]["description"] != undefined)
            "<p>" + data["query"]["pages"][wikiPage[i]]["description"] + "</p>"

        if (data["query"]["pages"][wikiPage[i]]["extract"] != undefined) {
            "<p>" + data["query"]["pages"][wikiPage[i]]["extract"] + "</p>"

        page.push(wiki + data["query"]["pages"][wikiPage[i]]["title"]);

  //When a term is typed, grab value and add it to the url for the API call and call Ajax function.
  $("#btn").on("click", function() {
    searchTerm = $("#search").val();
    url =
      "https://en.wikipedia.org/w/api.php?action=query&format=json&prop=pageimages%7Cdescription%7Cextracts&indexpageids=1&pageids=10&generator=search&piprop=thumbnail%7Cname&exsentences=1&exintro=1&excontinue=2&gsrsearch=" +
      searchTerm +

    //Hide the form inputs and show the recieved API data.

  $(".closebutton").on("hover", function() {
    $(this).css("cursor", "pointer");

  //On close empty results and show form ready for the next input.
  $(".closebutton").on("click", function() {

  //If a result is clinked forward me o the wikipedia page.
  $("#results").on("click", ".block", function() {
    urlLink = page[this.id.toString().substring(5)];

  //When a result is clicked determine its ID
  $("#container").on("click", ".added_element", function() {
    var id = $(this).attr("id");

  //If random button is clicked open a random wiki article.
  $("#randombtn").on("click", function() {


}, function(){

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................