Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

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.

+ 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.


Auto Save

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.



<div class="tab">
  <button class="tablinks" onmouseover="openCity(event, 'London')">
  <button class="tablinks" onmouseover="openCity(event, 'Paris')">
  <button class="tablinks" onmouseover="openCity(event, 'Tokyo')">

<div id="London" class="tabcontent">
  <p>London is the capital city of England.</p>

<div id="Paris" class="tabcontent">
  <p>Paris is the capital of France.</p>

<div id="Tokyo" class="tabcontent">
  <p>Tokyo is the capital of Japan.</p>

<div class="clearfix"></div>


                * {
  box-sizing: border-box;
body {
  font-family: "Lato", sans-serif;

/* 设置选项卡样式 */
.tab {
  float: left;
  border: 1px solid #ccc;
  background-color: #f1f1f1;
  width: 30%;
  height: 300px;

/* 设置用于打开选项卡内容的按钮的样式 */
.tab button {
  display: block;
  background-color: inherit;
  color: black;
  padding: 22px 16px;
  width: 100%;
  border: none;
  outline: none;
  text-align: left;
  cursor: pointer;
  font-size: 17px;

/* 更改悬停按钮的背景色 */
.tab button:hover {
  background-color: #ddd;

/* 创建 active/current “tab button”类 */
.tab {
  background-color: #ccc;

/* 设置选项卡内容的样式 */
.tabcontent {
  float: left;
  padding: 0px 12px;
  border: 1px solid #ccc;
  width: 70%;
  border-left: none;
  height: 300px;
  display: none;

/* 清除选项卡后的浮动 */
.clearfix::after {
  content: "";
  clear: both;
  display: table;


                function openCity(evt, cityName) {
  // 声明所有变量
  var i, tabcontent, tablinks;

  // 使用class=“tabcontent”获取所有元素并隐藏它们
  tabcontent = document.getElementsByClassName("tabcontent");
  for (i = 0; i < tabcontent.length; i++) {
    tabcontent[i].style.display = "none";

  // 使用class=“tablinks”获取所有元素并删除类“active”
  tablinks = document.getElementsByClassName("tablinks");
  for (i = 0; i < tablinks.length; i++) {
    tablinks[i].className = tablinks[i].className.replace(" active", "");

  // 显示当前选项卡,并向打开该选项卡的链接添加“active”类
  document.getElementById(cityName).style.display = "block";
  evt.currentTarget.className += " active";