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


Babel includes JSX processing.

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


Add Packages

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.


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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


  <!-- This is a javascript library called jQuery that is nice to use for ajax calls -->
  <script src=""></script>
  <!-- Importing Bootstrap, a styling library -->
  <link rel="stylesheet" href="" integrity="sha384WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<!--  Importing FontAwesome, a library for icons -->
  <link rel="stylesheet" href="" integrity="sha384-G0fIWCsCzJIMAVNQPfjH08cyYaUtMwjJwqiRKxxE/rx96Uroj1BtIQ6MLJuheaO9" crossorigin="anonymous">

  <!-- This is my own javascript -->
  <script src="apicall.js"></script>


  <div class="container">
    <h1>StarWarsAPI example</h1>

    <!--Here is where the magic happens! 
By using the onclick attribute for button 
we can make a call to our javascript function. 
Check it out in the apicall.js!  -->
    <button type="button" class="btn btn-primary" onclick="getData();">
      Get random character
      <i class="fa fa-sync"></i>
    <div class="container data-holder invisible">
      <div>Name: <span id="name"></span></div>
      <div>Height: <span id="height"></span></div>
      <div>Mass: <span id="mass"></span></div>
      <div>Hair Color: <span id="hair_color"></span></div>
      <div>Skin Color: <span id="skin_color"></span></div>
      <div>Eye Color: <span id="eye_color"></span></div>
      <div>Birth Year: <span id="birth_year"></span></div>
      <div>Gender: <span id="gender"></span></div>



                body {
  background: #000

.container {
  color: #fff;



                function getData() {
  //randomNumber is assigned a random value between 1 and 87 - that is how many star wars characters this API contains 
  const randomNumber = Math.floor(Math.random() * 87) + 1;
  //To use a function from the jQuery lib we just use $ then the function we want to call.
    //This is the url to the api:
    url: "" + randomNumber,

    //This is where we handle the response from the API.
    //Data is just a name, you can call it "response" or anything you like!
    success: function(data) {
      //Find the div by using $ and the id of the the div.
      //Use JSON.stringify to transform the response data into text that the browser can handle. From the data object we pick out the properties we want to display on the page ex. name, height...