HTML Easy

Practical SQL course for Product Managers, Marketers, Designers, Software Engineers, CEOs and more. Learn with hundreds of bite-sized exercises which could be applied in real job right away.

How to Add Tabs in HTML: A Step-by-Step Guide for Beginners

Looking to streamline your website’s content with HTML tabs? You’re in the right place! I’m here to provide a simple, straightforward guide on how to add tabs in HTML. Tabs are an efficient way to organize and present information on your website, making it more user-friendly and visually appealing. They can help declutter your web pages by dividing content into neat sections that users can click through at their leisure.

Adding tabs might seem complex if you’re new to coding but fear not – it’s actually much simpler than you’d think.  HTML , short for Hypertext Markup Language, is designed for ease of use even for beginners. With a basic understanding of the language’s syntax and structure, you’ll be adding tabs like a pro in no time.

So buckle up as we dive into the world of HTML tab creation! This guide will cover everything from the basics of tabbed content design to implementing code snippets efficiently. By the end, you’ll have all the tools and knowledge needed to enhance your web pages with functional, stylish tabs.

Let’s dive into the world of HTML, shall we? It’s a language that forms the backbone of most web pages and applications. A basic understanding of its structure will help you grasp how to add tabs in HTML with ease.

You might be wondering, what exactly is HTML? Hypertext Markup Language (HTML), as it’s formally known, is a standard markup language used for creating web pages. It utilizes tags enclosed in angle brackets like  <html> ,  <body> , and  <p>  to name a few. These tags instruct your browser on how to display content such as text, images, and links.

Now, let me give you an idea about the basic structure of an HTML document. Every webpage starts with a  <!DOCTYPE html>  declaration that tells the browser which version of HTML is being used. This is followed by the opening  <html>  tag and closing  </html>  tag which enclose all other elements.

Between these two tags you’ll find two main sections: The head ( <head> ) and body ( <body> ).

  • The  <head>  section contains metadata about the page like its title (which appears in browser tabs) and links to stylesheets or scripts.Example: <head> <title>This Is My Web Page Title</title> </head>
  • The  <body>  section holds everything that users can see – text, images, videos etc.Example: <body> <h1>Welcome To My Web Page!</h1> <p>This is where all visible content goes.</p> </body>

Each time we use these tags within our HTML code, we’re essentially adding different layers or ‘tabs’ if you will. Each one has its unique role in shaping what we see when browsing websites.

In our next section on “Creating Tabs with HTML”, I’ll guide you on how to use these tags and more, so you can start creating your own web pages. Stay tuned!

Decoding the Role of Tabs in HTML

Let’s take a step back and understand what tabs are for. In essence, they’re all about organization. When you’re dealing with large chunks of content on your webpage, it’s easy for things to get messy and confusing. That’s where tabs come in handy! They can help break down information into smaller, more digestible sections.

Take a look at this simple example:

In this case, we’ve created two tabs named “London” and “Paris”. Clicking on each tab reveals the corresponding content beneath it.

But wait – there’s more! You aren’t just limited to organizing text with tabs. You can also use them to display images, videos or even include other HTML elements like forms or tables – the possibilities are endless!

Here’s another variation using pictures inside your tabs:

In this example, each tab reveals a different image when clicked.

By now, I hope it’s clear how incredibly versatile tabs are in HTML. They’re not just for aesthetics – they play a crucial role in improving your website’s usability and overall user experience. So go ahead, add some tabs to your HTML and watch as your webpage transforms from chaotic to clean!

Step-by-Step Guide: Adding Tabs in HTML

Let’s dive right into the core of our discussion – adding tabs in HTML. If you’ve been around the block with coding, you’ll know that HTML doesn’t natively support tabs. But don’t let that discourage you! There are some workarounds using CSS and JavaScript to achieve this.

To start off, we’ll need a basic structure for our tabs. Here’s a quick example:

Each “tabcontent” div represents a separate tab. Note how each tab has its own unique ‘id’ attribute? That’s going to be important later on when we add interactivity.

Next up, we’re going to style our tabs using CSS. By applying different styles to the “tabs” and “tabcontent” classes, we can make it look like traditional tabs:

In this example, I’ve hidden all tab contents by default with ‘display:none’. The padding is added just for aesthetic purposes.

Now comes the real fun part – adding interactivity using JavaScript! With just a few lines of code, we can make those static divs behave like proper tabs:

This function hides all tabs, then displays the one with the ID matching the ‘tabName’ parameter. Call this function when a tab is clicked, passing in the event and tab’s ID as parameters.

Now that we’ve got our tabs set up and functioning, let’s add some flair. HTML5 allows us to use data attributes for storing custom information. We can use this feature to store additional data related to each tab:

By mixing HTML, CSS, and JavaScript like this, you can create functional tabs despite HTML’s limitations. Remember to play around with different styles and features to make your tabs truly unique!

Troubleshooting Common Issues While Adding Tabs

When diving into the world of HTML, adding tabs can sometimes feel like a daunting task. You might encounter some common issues that may seem perplexing at first. But don’t worry, I’m here to help you navigate through them.

One issue you might come across is poorly formatted HTML code which could lead to your tabs not displaying correctly. Let’s say your code looks something like this:

If you find your tabs are not working properly, double-check everything from your opening  <div>  tags to making sure all attributes are in their correct places. Remember that attention to detail is key in HTML coding!

Another common hiccup comes from forgetting to include JavaScript for tab functionality. Although the structure and content of each tab live within the HTML code, it’s JavaScript that provides interaction and brings those tabs to life! Don’t forget this important piece of the puzzle. Here’s how a small bit of JavaScript for our London example would look:

Finally, always ensure that your browser is up to date. Outdated browsers might not support some HTML or JavaScript functionalities, which could be the root cause of your tabs not working as expected.

So remember: meticulously check your HTML code structure, don’t forget about including JavaScript for interactivity, and keep your browser updated. These simple steps will help you avoid common issues when adding tabs in HTML. Happy coding!

Conclusion: Mastering Tabs for Effective HTML Coding

And there you have it! We’ve successfully navigated through the ins and outs of adding tabs in HTML. I hope this guide has left you feeling confident and ready to implement tabs into your own code.

Remember, mastering HTML requires practice. So don’t be discouraged if it doesn’t come naturally at first. The beauty of coding lies within its endless possibilities, so experiment with different techniques until you find what works best for you.

Let’s quickly recap what we’ve covered:

  • How to create a basic tab structure using  <div>  tags.
  • Using CSS to style our tabs, giving them a sleek and professional appearance.
  • Implementing JavaScript to enhance functionality, allowing users to interact with our tabs.

Here’s one last example of how an optimized tab might look in your HTML code:

In this example, we’re using buttons as our clickable links that trigger JavaScript functions to display different content.

Implementing tabs effectively in HTML can drastically improve your user interface, making your website more intuitive and easy to navigate. It’s a small detail that makes a big difference. So go ahead, roll up those sleeves and start coding! I’m confident that you’ll master the art of HTML tabs in no time.

how to create html new tab

Cristian G. Guasch

Related articles.

  • How to Make a Vertical Line in HTML: A Simple Guide for Beginners
  • How to Disable a Button in HTML: Your Quick and Easy Guide
  • How to Make Checkboxes in HTML: My Simple Step-by-Step Guide
  • How to Make a Popup in HTML: A Simple, Step-by-Step Guide for Beginners
  • How to Float an Image in HTML: Simplifying Web Design for Beginners
  • How to Use iFrame in HTML: A Comprehensive Beginner’s Guide
  • How to Add Audio in HTML: A Comprehensive Guide for Beginners
  • How to Print in HTML: Your Essential Guide for Webpage Printing
  • How to Draw Lines in HTML: A Swift and Simple Guide for Beginners
  • How to Add Canonical Tag in HTML: Your Easy Step-by-Step Guide
  • How to Make Slideshow in HTML: Your Quick and Easy Guide
  • How to Use Span in HTML: Unleashing Your Web Design Potential
  • How to Embed Google Map in HTML: A Quick and Easy Guide for Beginners
  • How to Add SEO Keywords in HTML: My Simplified Step-by-Step Guide
  • How to Add a GIF in HTML: A Simple Guide for Beginners
  • How to Change Fonts in HTML: Your Ultimate Guide to Web Typography
  • How to Make an Ordered List in HTML: A Straightforward Guide for Beginners
  • How to Add Bullet Points in HTML: Your Quick and Easy Guide
  • How to Move Text in HTML: My Expert Guide for Web Developers
  • How to Unbold Text in HTML: A Straightforward Guide for Beginners
  • How to Create Pages in HTML: A Step-by-Step Guide for Beginners
  • How to Use PHP in HTML: An Expert’s Guide for Seamless Integration
  • How to Make Multiple Pages in HTML: A Comprehensive Guide for Beginners
  • How to Embed a Website in HTML: Your Simple Guide to Seamless Integration
  • How to Create a Box in HTML: A Simple Guide for Beginners
  • How to Make a Search Bar in HTML: Simplified Steps for Beginners
  • How to Add Padding in HTML: A Simple Guide for Web Design Beginners
  • How to Send HTML Email in Outlook: Your Step-by-Step Guide
  • How to Make a Form in HTML: Your Easy Guide for Better Web Design
  • How to Put Text Next to an Image in HTML: A Simple Guide for Beginners
  • How to Use Div in HTML: Your Ultimate Guide on Mastering Division Tags
  • How to Wrap Text in HTML: Mastering the Art of Web Design
  • How to Redirect to Another Page in HTML: A Simple, Effective Guide for Beginners
  • How to Center a Div in HTML: My Expert Guide for Perfect Alignment
  • How to Add a Target Attribute in HTML: A Simple Guide for Beginners
  • How to Link Email in HTML: My Simple Guide for Beginners
  • How to Use JavaScript in HTML: A Comprehensive Guide for Beginners
  • How to Make List in HTML: A Comprehensive Guide for Beginners
  • How to Make a Button in HTML: A Simple Guide for Beginners
  • How to Add a Line Break in HTML: Your Quick and Easy Guide
  • How to Embed a Video in HTML: A Simplified Guide for Beginners
  • How to Add a Favicon in HTML: Your Easy Step-by-Step Guide
  • How to Change Font Size in HTML: A Simple Guide for Beginners
  • How to Center a Table in HTML: Streamlining Your Web Design Skills
  • How to Add Space in HTML: Your Guide for a Cleaner Code Layout
  • How to Change Image Size in HTML: Your Quick and Easy Guide
  • How to Indent in HTML: A Simple Guide for Beginners
  • How to Add a Link in HTML: Your Easy Step-by-Step Guide
  • How to Make a Table in HTML: Your Ultimate Guide to Mastery
  • How to Add an Image in HTML: A Step-by-Step Tutorial for Beginners

How to Open a Link in a New Tab – HTML target blank Attribute Explained

Jessica Wilkins

There will be times where you will want your user to click on a website link and have it open in a new browser tab. But how do you do that in HTML?

In this article, I will show you how to use the target="_blank" attribute through code examples. I will also talk about when you should consider using this attribute.

How to Open Up a New Browser Tab Using target="_blank"

The target="_blank" attribute is used inside the opening anchor tag like this:

When the user clicks on the link, a new browser tab will automatically open to that page.

In this example, I have nested a link inside a set of paragraph tags to direct people to freeCodeCamp.

When you click on the freeCodeCamp link, then it will open up a new browser tab for you.

If I were to omit the target="_blank" attribute, then the default behavior would be to leave the current web page and go directly to the link without opening a new browser tab.

What is the noopener Keyword?

The noopener keyword in the rel attribute is used primarily for security reasons to prevent malicious users from messing with the original web page through the Window.opener property. If the malicious user gained access to your window object then they could redirect your page to a malicious URL.

You can use the noopener keyword as a way to help prevent that security issue from happening. Here is how the noopener keyword is used:

If you want to learn more about the security concerns that rel=noopener helped solve, then please read through this helpful article .

Updates to the noopener keyword

In 2021, there was an update made where modern browsers now set rel=noopener to any link using the target=_blank attribute. As you can see in this Can I use table , the noopener keyword is supported by most browsers except for Internet Explorer 11.

Even with this update, a lot of developers will still use rel=noopener for links using the target=_blank attribute.

Should You Use the target="_blank" Attribute All the Time?

When users click on a link, the default behavior is to have that link open on the current page they are on without opening a new browser tab. In a lot of cases, you do not want to change this default behavior because users have grown to expect this.

You have to think carefully about when it would be a good time to use the target="_blank" attribute. One good example would be if a user is working on a page and they don't want to leave that page if they click on a link.

In this example, we are linking to the DevDocs documentation, so the user can stay on their current page and look up a reference on a new tab.

You can use the target="_blank" attribute if you want your users to click on a link that opens up a new browser tab.

The target="_blank" attribute is used inside the opening anchor tag like this.

The noopener keyword in the rel attribute is added to prevent malicious users from messing with the original web page through the Window.opener property.

You have to think carefully about when it would be a good time to use the target="_blank" attribute because you don't want to always change the default behavior of links.

I hope you enjoyed this article and best of luck on your programming journey.

I am a musician and a programmer.

If you read this far, thank the author to show them you care. Say Thanks

Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. Get started

Coding Beast

How to Open Links in a New Tab Using HTML and JavaScript

by jovana | Jan 10, 2024

How to Open Links in a New Tab Using HTML and JavaScript

Introduction How to Open Links in a New Tab Using HTML and JavaScript

Safety tip for target=’_blank’, what is tabnabbing.

Have you ever clicked on a link and wished it would open in a new tab instead of navigating away from the current page? Well, you’re in luck! In this blog post, we’ll guide you through the simple process of opening links in a new tab using HTML and JavaScript.

To make a link open in a new tab using HTML, we add a special instruction in the link’s starting <a> tag. We use the target attribute and set it to _blank. So, when someone clicks on the link, the website opens in a fresh tab. It’s that easy!

Let’s start with the HTML markup. In your HTML file, locate the link you want to open in a new tab and add the target attribute to it. Set the “target” attribute to “_blank,” and this will instruct the browser to open the link in a new tab.

If you want to enhance the user experience further or have more control over link behavior, you can use JavaScript. Below is a simple example using JavaScript to open links in a new tab when clicked.

The <a> element in HTML helps add web addresses, known as URLs, to websites.

The href attribute decides where the user goes when they click the link. For example, the URL https://www.example.com/ is the href value.

The target attribute decides how the link opens. When set to _blank , it opens in a new tab.

The text between <a> and </a> , like ‘Visit Example.com,’ is what you see as the clickable link on the page.

I advise always adding rel="noreferrer noopener" to your link (anchor) when using ‘target.’ This ‘rel’ attribute sets a safety relationship with the linked URL. Adding ‘noopener noreferrer’ helps guard against a phishing trick called tabnabbing.”

Tabnabbing , also known as reverse tabnabbing, is a trick that takes advantage of how browsers behave with target="_blank" . It uses this to gain partial access to your page through the window.object API.

In tabnabbing, a page you link to can make your page redirect to a fake login page. Most users might not notice because the focus is on the newly opened tab, not the original one with your page.

Later, when someone switches back to your tab, they might see the fake login page instead and unknowingly enter their login details.

Inside openTab() , we use window.open() to create a new tab. We specify the website link. The ‘target’ attribute is set to ‘_blank’, ensuring the link opens in a new tab.”

And that’s it! You’ve successfully learned how to open links in a new tab using HTML and JavaScript. Whether you prefer a simple HTML approach or want to add some styling and interactivity with CSS and JavaScript, these techniques will give you the flexibility to create a better browsing experience for your users. Feel free to experiment and adapt these methods to suit your website’s needs. Happy coding!

Submit a Comment Cancel reply

Your email address will not be published. Required fields are marked *

Save my name, email, and website in this browser for the next time I comment.

Submit Comment

Looking For Something?

Related articles.

How to Create Custom Hooks in React: Simplified Guide with Examples

How to Create Custom Hooks in React: Simplified Guide with Examples

Heard about custom hooks but not sure how to harness their power? In this blog post, we’ll delve into the wonderful world of custom hooks in React, breaking down what they are, how to create them, and why they’re a game-changer for your projects. What Are Custom...

How to create Bootable USB and install Ubuntu

How to create Bootable USB and install Ubuntu

Deciding which version of Linux to put on your computer can be hard because there are a lot of options, and each one has its own unique features. One choice that many people like is Ubuntu. Some say it's one of the top Linux options out there. It's easy to use, you...

Subscribe To Our Newsletter

Subscribe To Our Newsletter

Join our mailing list to receive the latest news and updates from our team.

You have Successfully Subscribed!

Logo for thesitewizard.com

How to Make Links Open in a New Window or Tab

HTML code for opening links in a new browser tab or window

I was asked by a visitor how he could make hyperlinks on his website open a new browser window or tab when clicked. This article answers that question.

Prerequisites

Since the visitor did not specify which web editor he was using, I will assume here that he is working directly in HTML.

Note that this does not mean you cannot follow this tutorial if you use a visual web editor , or if your website uses some sort of blogging software . It merely means that you will need to somehow access the HTML code of your page so that you can modify it. Most web editors and blogging software allow you to do this.

For example, if you are using Expression Web, you can modify the HTML code of your web page by switching to the Code mode. Instructions for this can be found in the article How to Insert HTML Code into a Web Page with Expression Web . Similarly, Dreamweaver users can follow the steps given in How to Insert Raw HTML Code in Dreamweaver , BlueGriffon users the tutorial How to Insert HTML Code in BlueGriffon , and KompoZer users the guide How to Insert HTML in KompoZer .

How to Open Hyperlinks in a New Browser Tab or Window

The short answer is: just add a target="_blank" attribute to your links (anchor tags).

For example, if you have a link that says the following:

Change the above so that it now says:

Now when your visitors click that link, it will open in a new window or tab (depending on which web browser they are using and how they configured that browser).

Note that if your web page uses the "strict" DOCTYPE of XHTML 1.0 or 1.1, you will not be able to do the above and still have your page validate as correct . However, I suspect virtually nobody uses those, so don't worry if you don't understand what I just said in this paragraph. The "transitional" versions of those DOCTYPEs are fine, though, since the target attribute is still supported there.

If you are using Expression Web, Dreamweaver, BlueGriffon or KompoZer, just click somewhere in the link that you want to modify, switch to the mode that allows you to change the HTML code (see the tutorials listed earlier in the Prerequisites section to find out how to do this), and add the target="_blank" attribute.

It Doesn't Have the Benefit You Think It Confers

I know that some new webmasters seem to have got the impression that causing external links to open in a new window helps to keep people from leaving your website. This is an erroneous assumption. If someone clicks on a link and wants to return to your site, they will simply hit the Back button on their browser. Most people, even non-computer-geeks, learn this feature of their browser within a short time of discovering the Internet. The power users learn, in addition, how to right click a link and select "Open in a new tab" (or window) when they need a link to be displayed in a separate tab or window.

When you create links that open in a new window, you are actually preventing newcomers from returning to your website . You may think that they will know how to simply switch back to the original window. My experience with such people suggests otherwise; they are stymied by the Back button not working, and are not even aware that they are looking at a new tab or window. When they can't figure out how to solve the problem, they will give up and move on to other things.

The situation is not better with experienced users. While they can figure out that they are looking at a new tab or window, and can switch back, they tend to get very irritated at your site for opening windows without their permission. After all, they are power users: if they wanted to open a new window, they will open it themselves; they don't want you to do it without their consent. It's worse if all your links open in new windows (leading to the comedic situation described in my article about usability mistakes made by amateur webmasters ).

It Makes Your Site Vulnerable to Phishing Attacks

At the time this is written, when you open a new page with target="_blank" , the site you link to gains access to the window/tab containing your page and is able to change it (in the visitor's browser) to display a different web address.

This not only thwarts your attempt to keep visitors at your site (if that's your purpose), it's also a potential danger to them. For example, if you have a login page, the linked-to site may replace it with one on another site that looks like yours, but actually collects your visitor's login details. This kind of attack is called "phishing". Even if your site does not have facilities for visitors to log in, the linked-to site can replace it with a page that delivers malware.

This vulnerability is not hypothetical. The people from the Google Security Team have noted a "significant number of reports" of such "tabnabbing" being used to deliver malware.

Technical details (only for those who are interested): the newly open site gains limited access to your page via the JavaScript window.opener object. This is a read/write object that they can manipulate. It has a property called window.opener.location that can be changed, causing the browser to go to a new URL instead of staying at your page. If you don't understand this paragraph, skip it. It's merely the technical version of the explanation given earlier.

You can prevent it from happening in some browsers by adding rel="noopener noreferrer" to your link. With this added, the above example becomes:

Theoretically, either rel="noopener" or rel="noreferrer" is sufficient to prevent this problem, with rel="noopener" being the correct attribute to use. (The other one, rel="noreferrer" , has a side-effect in that the browser will also withhold the referring URL.) However, at this time, not all browsers support rel="noopener" . Likewise, rel="noreferrer" is also not supported by some browsers. Since the list of browsers that support either attribute is not identical, if you want this protection from the greatest subset of browsers possible, you will probably need to use both.

That said, the workaround only helps with the later versions of Chrome, Firefox and Safari. Internet Explorer does not have such a facility, although from my cursory test, version 11 seems to be immune to the attack in its default security zone. I'm not sure about Microsoft Edge.

In other words, the method detailed above is not 100% foolproof. The best way to avoid the problem is to use normal links , without target="_blank" .

My general recommendation is to avoid opening links in a new window or tab, if possible. Of course there may be specific instances where this is needed (which is why such a facility exists in the first place, for those rare cases where it may be required). If so, you may want to warn your visitors by saying something like "opens in a new window" next to your link (if it's appropriate). It won't help the average Internet user, who won't know what you are talking about or how to deal with it, and it won't guard them from attacks using your site, but at least you will won't irritate the more experienced Internet visitors.

Copyright © 2015-2019 Christopher Heng. All rights reserved. Get more free tips and articles like this , on web design, promotion, revenue and scripting, from https://www.thesitewizard.com/ .

You are here: Top > HTML Tutorials > How to Make Links Open in a New Window or Tab

Other articles on: HTML , Usability , FAQ

thesitewizard™ News Feed (RSS Site Feed) 

Do you find this article useful? You can learn of new articles and scripts that are published on thesitewizard.com by subscribing to the RSS feed. Simply point your RSS feed reader or a browser that supports RSS feeds at https://www.thesitewizard.com/thesitewizard.xml . You can read more about how to subscribe to RSS site feeds from my RSS FAQ .

Please Do Not Reprint This Article

This article is copyrighted. Please do not reproduce or distribute this article in whole or part, in any form.

Related Articles

  • How to Link to a Specific Line or Paragraph on a Web Page Using HTML
  • How to Make Your Links Change Colour When a Mouse Hovers Over It (Using CSS)
  • How to Remove the Underlining from Links (HTML/CSS)
  • How to Centre a DIV Block Using CSS
  • How to Create 3D Buttons Using CSS
  • Should I Learn HTML or Just Use a WYSIWYG Web Editor? Pros and Cons of Using a Visual Web Editor vs Learning HTML
  • How to Make / Create Your Own Website: The Beginner's A-Z Guide
  • How to Register Your Own Domain Name

New Articles

  • How to Set the Height of a DIV Relative to a Browser Window (CSS)
  • How to Generate the Free Let's Encrypt SSL Certificate on Your Own (Windows) Computer
  • How to Insert Meta Tags into a Web Page with BlueGriffon
  • How to Play a Song (or Some Other Audio Clip) from a List on a Website
  • How to Draw a Horizontal Line on a Web Page with Expression Web
  • How to Create a Website Free of Charge
  • Why Can't I Make Up Any Domain I Want? Is There a Way to Do Away with a Registrar Altogether?
  • What's the Difference Between a Domain Name Registrar and a Web Host?
  • How to Make a Mobile-Friendly Website: Responsive Design in CSS
  • What's the Difference Between a Content Management System (CMS), a Blog, a Web Editor and an Online Site Builder?

Popular Articles

  • How to Create a Blog
  • How to Make / Create a Website: The Beginner's A-Z Guide
  • Tips on Choosing a Good Domain Name
  • Expression Web Tutorial: How to Design a Website with Microsoft Expression Web
  • Dreamweaver Tutorial: How to Design a Website with Dreamweaver CS6
  • BlueGriffon Tutorial: How to Design a Website with BlueGriffon 3
  • How to Design and Publish Your Website with KompoZer (free WYSIWYG web editor)
  • Free Feedback/Contact Form Wizard

How to Link to This Page

To link to this page from your website, simply cut and paste the following code to your web page. (Switch to your web editor's HTML source mode before pasting.)

It will appear on your page as:

How TO - Full Page Tabs

Learn how to create full page tabs, that covers the entire browser window, with CSS and JavaScript.

Full Page Tabs

Click on the links to display the "current" page:

Home is where the heart is..

Some news this fine day!

Get in touch, or swing by for a cup of coffee.

Who we are and what we do.

Try it Yourself »

Create One Page Tabs

Step 1) add html:.

Create buttons to open specific tab content. All <div> elements with class="tabcontent" are hidden by default (with CSS & JS). When the user clicks on a button - it will open the tab content that "matches" this button.

Step 2) Add CSS:

Style the links and the tab content (full page):

Advertisement

Step 3) Add JavaScript:

Tip: Also check out How To - Tabs .

Get Certified

COLOR PICKER

colorpicker

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: [email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail: [email protected]

Top Tutorials

Top references, top examples, get certified.

how to create html new tab

Explore your training options in 10 minutes Get Started

  • Graduate Stories
  • Partner Spotlights
  • Bootcamp Prep
  • Bootcamp Admissions
  • University Bootcamps
  • Coding Tools
  • Software Engineering
  • Web Development
  • Data Science
  • Tech Guides
  • Tech Resources
  • Career Advice
  • Online Learning
  • Internships
  • Apprenticeships
  • Tech Salaries
  • Associate Degree
  • Bachelor's Degree
  • Master's Degree
  • University Admissions
  • Best Schools
  • Certifications
  • Bootcamp Financing
  • Higher Ed Financing
  • Scholarships
  • Financial Aid
  • Best Coding Bootcamps
  • Best Online Bootcamps
  • Best Web Design Bootcamps
  • Best Data Science Bootcamps
  • Best Technology Sales Bootcamps
  • Best Data Analytics Bootcamps
  • Best Cybersecurity Bootcamps
  • Best Digital Marketing Bootcamps
  • Los Angeles
  • San Francisco
  • Browse All Locations
  • Digital Marketing
  • Machine Learning
  • See All Subjects
  • Bootcamps 101
  • Full-Stack Development
  • Career Changes
  • View all Career Discussions
  • Mobile App Development
  • Cybersecurity
  • Product Management
  • UX/UI Design
  • What is a Coding Bootcamp?
  • Are Coding Bootcamps Worth It?
  • How to Choose a Coding Bootcamp
  • Best Online Coding Bootcamps and Courses
  • Best Free Bootcamps and Coding Training
  • Coding Bootcamp vs. Community College
  • Coding Bootcamp vs. Self-Learning
  • Bootcamps vs. Certifications: Compared
  • What Is a Coding Bootcamp Job Guarantee?
  • How to Pay for Coding Bootcamp
  • Ultimate Guide to Coding Bootcamp Loans
  • Best Coding Bootcamp Scholarships and Grants
  • Education Stipends for Coding Bootcamps
  • Get Your Coding Bootcamp Sponsored by Your Employer
  • GI Bill and Coding Bootcamps
  • Tech Intevriews
  • Our Enterprise Solution
  • Connect With Us
  • Publication
  • Reskill America
  • Partner With Us

Career Karma

  • Resource Center
  • Bachelor’s Degree
  • Master’s Degree

How to Open a Link in a New Tab Using HTML

When we want to direct a user to a third-party web page, the default behavior is for the link to go directly to that page in the same tab. You can keep users on your page by opening up the third-party external link in a new tab so your page is easy to navigate back to. This article covers how to do that.

This particular feature is straightforward. You need to add a target attribute and set it to _blank. Depending on the browser’s settings, it opens up in a new browser tab or a new browser window. The noreferrer and noopener rel attributes are one part masking where you’ve come from and one part prevention of a malicious attack. 

Find your bootcamp match

Noreferrer prevents SEO (search engine optimization) from noting where a particular user has come from. It shows up as a direct link instead. Noopener prevents a malicious html doc from accessing your document to do bad things. 

Here’s the whole codebase: 

About us: Career Karma is a platform designed to help job seekers find, research, and connect with job training programs to advance their careers. Learn about the CK publication .

What's Next?

icon_10

Get matched with top bootcamps

Ask a question to our community, take our careers quiz.

Christina Kopecky

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Apply to top tech training programs in one click

Computer Hope

How to create a link that opens a new web page window or tab

In HTML (hypertext markup language), to create a new window or tab when a link is clicked, add target="_blank" attribute in the a href tag, as shown below.

Realize that when opening a link in a new tab, you're changing the default behavior of how the browser operates. For some users, this change can be confusing and frustrating.

Below is an example of what the above code would create. If you click the link below, it opens the Computer Hope homepage in a new window or tab. Today, all new browsers open these types of links in new tabs.

Open Computer Hope in a new tab.

Tabnabbing security vulnerability

When opening a link is a new tab, the new tab gains partial access to the referring page through the window.opener object, which leaves the origin page vulnerable to tabnabbing .

Tabnabbing is a phishing technique that could change the origin page content or location, making it vulnerable to stealing user content. For example, if a link to a malicious page was opened in a new tab, it could switch the origin page's window.opener.location to a new location (e.g., fake login page). If the user attempted to log back into the site through the fake login page, they would have their login details shared with the attacker.

To prevent tabnabbing, add the rel="noopener no referrer" attribute to the links opening in a new tab. For example, below is the same code we used above with this attribute added to the tag.

For more information about this vulnerability, see: How to fix target="_blank" links: a security and performance issue in web pages.

Related information

  • How to create an HTML link on a web page.
  • How to create links to sections on the same page in HTML.
  • Open link in new window or tab.
  • See our hyperlink , tab , and window definitions for related links and information.
  • HTML and web design help and support.

How to Create Tabs with HTML

Updated: December 14, 2023

Published: May 29, 2023

HTML is the backbone of the internet. Without it, you wouldn’t have any content. Of course, it takes a lot more than just HTML  to create your typical web page, but it definitely builds the foundation for all of the other technologies that go into building a functional website.

coding tabs with html

One cool type of functional website uses the concept of tabs. Have you ever visited a website that seemingly loaded pages instantly upon clicking navigation buttons? It’s quite possible that the site used tabs to make that near-instant response happen.

Download Now: 25 HTML & CSS Hacks [Free Guide]

Learn what HTML tabs are and how to add them to your website.

Table of Contents

What are website tabs?

Html tabs in action.

Website tabs are a clever way to show chunks of content on demand at the click of a button. What makes them clever, though, is how they can condense what would be multiple different web pages of content into just one page — without the “one page” part even being apparent to the user. Even more clever, however, is exactly how that is accomplished.

Although there are multiple approaches to this, the site often loads all the content from all the pages at once, then simply hides or displays certain information depending on which tab the user selects. It’s like a magic trick that allows for many single-page web applications to be possible.

In this guide, we’ll focus on the HTML part of the equation, though we’ll briefly touch on CSS and JavaScript as necessary. Some approaches exclude JavaScript, but this guide will use it for simplicity.

Let’s take a look at an example of this concept working in action. Here's one from a website ranking football teams :

Each individual box is its own tab that you can click into and expand for more information. 

Can you imagine if you had to wait for a new web page to load every single time you clicked one of those boxes? The result would likely be something that feels clunky. Instead, this layout allows you to pack a lot of information onto a single web page without overloading the reader with text and visuals. 

Though largely beneficial, there’s one notable trade-off to using this technique. For example, though the tabs “Primary,” “Promotions,” and “Social” are being shown instantly upon getting clicked, they were all loaded simultaneously upon visiting the web page.

This can result in a longer load time upon visiting the web page. However, once past that initial load, everything else is ready to go at a moment’s notice.

Now, onto the actual task of replicating this effect. As previously discussed, this approach contains HTML, CSS, and JS, though there are different ways to accomplish the same behavior.

1. Create a folder.

To start, create a folder that will contain the files for your site. Then, create empty .html, .css, and .js files inside.

HTML tabs example file structure

While script element might look like this:

<script src="index.js."></script>

The script element linking the .js file should be at the end of your code. Otherwise, you risk having the script load before your HTML elements, which can break the functionality of your site. In our example, we're going to include the JavaScript directly on the HTML file. 

Lines 9-13 contain the buttons you will click on to display content on the page. Ignore the “tab” and “onclick” attributes for now. Just know that’s how we will refer back to these buttons when we get to the CSS and JavaScript portion of the guide.

HTML tab buttons

Lines 15-18, 20-23, and 25-28 are all of the tabs, or pages of content, respectively. Each page of content is contained within its own div element as well as an H2 and a paragraph tag to be displayed on the page.

HTML tab code example

Again, some simple text was used, but you could put images or videos here. The “id” and “class” properties will again be how we reference these elements later on, specifically in the CSS portion.

Without the CSS portion, all of this HTML would look pretty plain at best and confusing to navigate at worst. So without further delay, let’s move on to the CSS, which is important for formatting and styling our above HTML.

3. Set up the CSS.

The CSS is important for styling and formatting the tabs and their content.  CSS property is also used to display or hide the content itself. In the Code Pen below, you can access the CSS file via the CSS tab in the top corner:

Lines 1-6 style the body of the page. In this case, we're using it to style the page's background and to designate the font used throughout the page.

Lines 8-12 style the tab container which is the area of the page that the HTML tab buttons are positioned in. In this case, we're using justify-content and margin-top to center the tabs on the page.

Lines 14-18 apply to all elements that have the “tab” class attribute back in the HTML file, which specifically refers to the div element on lines 10, 11, and 12.

Create HTML tab using tab class attribute

Lines 20-22 affect the actual content on each tab. You'll notice we've set the display  property to none . This prevents the tab content from displaying when the page loads, requiring users to click on the buttons in order to view the content. Without this property, you would see the content from all three tabs loaded automatically on the page. 

example of html tab code

Lines 24-26 style the tab button after it's been clicked on. In this case, I've chosen a dark green to show that the button was clicked, but you can edit the background-color property to be any color you'd like.  

Lastly, lines 28-30 will style the actual content of the HTML tab. I've set the display property to block so the content will display itself after the button has been clicked on. You can add additional properties here to further style your tab content. 

how to create html new tab

Now, even with all of that HTML and CSS working together, your web page is still incapable of functionality. If you were to load this up right now, everything would be on the page all at once. To finish the process, you need the power of JavaScript.

4. Set up the JavaScript.

JavaScript is where all of the magic happens. It allows you to change things about your HTML and CSS upon events. In this case, your event will consist of clicking a button with your mouse.

As we mentioned earlier, you can link to your JavaScript file or include it directly within the HTML. This JS code may look something like this:

Line 31 defines a JavaScript function called "openTab" which takes the parameter "tabId." This function will power the tab-switching logic. 

Line 33 pulls in all of the elements that have the class "tab-content" and stores them in the variable named "tabContents." This is the content you'll display on your tab and the next line of code hides them from view by setting the display property to none . 

JS code for HTML tabs

The next block of code indicates your active tab. Line 39 stores all elements with the "tab" class in the "tabs" variable.  Line 40 removes the class " active-tab," applying the proper styling to the correct tag.

Finally, lines 44-47 show the selected tab's content and marks it as active. L ine 46 adds the class " active-tab" to the tab that was clicked, marking it as the active tab. It also uses document.querySelector to select the tab based on its onclick attribute.

HTML tabs js code example

When all is said and done, open up the index.html file in any web browser, and you should have something like this:

Need a few more tips? Check out this video below to see this process in action.

Building Your First HTML Tab

Now that you’ve made it through to the end of this guide, you can keep building on top of everything that’s been covered. Not only did you learn about the HTML portion of tabs, but also some CSS and JavaScript magic along the way. These are invaluable skills that can be applied in many web projects going forward.

coding-hacks

Don't forget to share this post!

Related articles.

How to Create an HTML Dropdown Menu [+ Examples]

How to Create an HTML Dropdown Menu [+ Examples]

Onchange Event in HTML: How to Use It [+Examples]

Onchange Event in HTML: How to Use It [+Examples]

HTML Dialog: How to Create a Dialog Box in HTML

HTML Dialog: How to Create a Dialog Box in HTML

How to Create a Landing Page in HTML & CSS [+ 15 Templates]

How to Create a Landing Page in HTML & CSS [+ 15 Templates]

HTML Audio Tag: How to Add Audio to Your Website

HTML Audio Tag: How to Add Audio to Your Website

How to Add an Image & Background Image in HTML

How to Add an Image & Background Image in HTML

How to Call a JavaScript Function in HTML

How to Call a JavaScript Function in HTML

How to Embed Google Map in HTML [Step-By-Step Guide]

How to Embed Google Map in HTML [Step-By-Step Guide]

How to Create a Range Slider in HTML + CSS

How to Create a Range Slider in HTML + CSS

How to Create an HTML Tooltip [+ Code Templates]

How to Create an HTML Tooltip [+ Code Templates]

Tangible tips and coding templates from experts to help you code better and faster.

CMS Hub is flexible for marketers, powerful for developers, and gives customers a personalized, secure experience

Creating Toggleable Tabs with HTML, CSS, and JavaScript

Faraz

By Faraz - September 06, 2023

Learn how to create toggleable tabs with HTML, CSS, and JavaScript. Elevate your front-end development game.

Creating Toggleable Tabs with HTML, CSS, and JavaScript.jpg

Table of Contents

  • Project Introduction
  • JavaScript Code

Toggleable tabs are a fantastic way to organize and present content on your website in an organized and user-friendly manner. In this tutorial, we'll guide you through the process of creating toggleable tabs using HTML, CSS, and JavaScript.

Toggleable tabs not only enhance user experience but also add a professional touch to your web development skills. By combining these three essential web technologies, you can take your website's user interface to the next level. In this comprehensive guide, we'll provide step-by-step instructions, clear code examples, and best practices to help you master the art of creating interactive tabs. Whether you're a beginner or an experienced developer looking to enhance your skills, this tutorial is designed to empower you with the knowledge and tools needed to implement toggleable tabs effectively.

So, let's dive in and discover how to build engaging and interactive tabs for your web projects. Whether you're designing a portfolio, a blog, or an e-commerce website, toggleable tabs can make a significant difference in how your content is presented and accessed by users. Start creating stunning and user-friendly tabbed content today!

Source Code

Step 1 (HTML Code):

To get started, we will first need to create a basic HTML file. In this file, we will include the main structure for our toggleable tabs.

After creating the files just paste the following codes into your file. Make sure to save your HTML document with a .html extension, so that it can be properly viewed in a web browser.

Let's break down each part of the code:

1. <!DOCTYPE html> : This is the document type declaration and specifies that the document is an HTML5 document.

2. <html> : This is the opening tag for the HTML document, enclosing all the HTML content.

3. <head> : This section contains metadata about the document, such as the title, character encoding, and viewport settings.

  • <title> : Sets the title of the webpage, which is displayed in the browser's title bar or tab.
  • <meta charset="UTF-8" /> : Specifies the character encoding of the document as UTF-8, which supports a wide range of characters and symbols.
  • <meta name="viewport" content="width=device-width" /> : This meta tag defines the viewport settings for responsive design, ensuring that the webpage adapts to the device's screen width.
  • <link rel="stylesheet" href="styles.css" /> : This line links an external CSS stylesheet named "styles.css" to the HTML document. CSS is used for styling and formatting the webpage.

4. <body> : This section contains the visible content of the webpage.

5. <div class="tab-buttons"> : This div element is a container for the tab buttons, which are used to switch between different tabs of content.

  • Inside the div, there are three <button> elements, each with a class of "tab-button" and one of them is initially set as "active-tab-button". These buttons represent the individual tabs. The onclick attribute specifies a JavaScript function, toggleTab(), to be executed when the button is clicked, with a different argument for each button to identify which tab to display.

6. <div class="tab" id="tab1"> : This div element represents the content of the first tab with the ID "tab1". It is initially visible when the page loads.

  • Inside the div, there is an <h2> element displaying "Tab 1 Content" as the heading, and a <p> element with a description of the content for Tab 1.

7. Similar div elements with different IDs (" tab2 " and " tab3 ") represent the content for the other two tabs, with corresponding headings and descriptions.

8. <script src="script.js"> </script> : This line includes an external JavaScript file named "script.js" to the HTML document. JavaScript is used to implement the functionality of toggling between tabs.

This is the basic structure of our toggleable tabs using HTML, and now we can move on to styling it using CSS.

Tab 1 Content

Description for Tab 1 goes here.

Tab 2 Content

Description for Tab 2 goes here.

Tab 3 Content

Description for Tab 3 goes here.

Create a Stunning Shake Input Effect with HTML, CSS, and JavaScript.jpg

Step 2 (CSS Code):

Once the basic HTML structure of the toggleable tabs is in place, the next step is to add styling to the tabs using CSS.

Next, we will create our CSS file. In this file, we will use some basic CSS rules to create our tabs.

  • This section styles the entire body of the web page.
  • It sets the background color to a light gray (#eee).

2. .tab-buttons :

  • This styles a container element that holds the tab buttons.
  • It uses the CSS display property with the value flex to arrange the buttons horizontally in a row.

3. .tab-button :

  • This styles individual tab buttons inside the .tab-buttons container.
  • It sets the background color of the button to white (#ffffff).
  • Removes the border around the button with border: none.
  • Adds padding of 10 pixels on the top and bottom and 20 pixels on the left and right to create some space inside the button.
  • Changes the cursor to a pointer when hovering over the button.
  • Sets a fixed height of 40 pixels for the button.

4. .tab-button:hover :

  • This styles the tab button when the mouse pointer hovers over it.
  • It changes the background color to a slightly darker gray (#ddd) when the button is hovered.
  • This styles the content that appears when a tab is active.
  • It sets the display property to none, which means the content is initially hidden.
  • It gives the content a width of 70% of its container.
  • Adds padding of 20 pixels around the content.
  • Sets the background color to a light gray (#ccc).

6. .active-tab-button :

  • This styles the tab button that corresponds to the currently active tab.
  • It changes the background color to the same light gray (#ccc) as the tab content.
  • Applies a scaling transformation (transform: scaleY(1.1)) to make the button slightly taller (110% of its original height).
  • Specifies the transformation origin to be at the bottom of the button (transform-origin: bottom), so it grows upward.

This will give our toggleable tabs an upgraded presentation. Create a CSS file with the name of styles.css and paste the given codes into your CSS file. Remember that you must create a file with the .css extension.

Step 3 (JavaScript Code):

Finally, we need to create a function in JavaScript. This JavaScript code defines a function called toggleTab and then immediately calls it with the argument 0. Let's break down what this code does step by step:

1. function toggleTab(tabIndex) { ... } : This line defines a function named toggleTab that takes one parameter, tabIndex. This parameter represents the index of a tab that you want to display as active.

2. var tabs = document.getElementsByClassName("tab"); : This line selects all elements with the class name "tab" from the HTML document and stores them in the tabs variable. These elements are typically the content containers for different tabs in a tabbed interface.

3. for (var i = 0; i < tabs.length; i++) { ... } : This is a for loop that iterates through all the elements in the tabs collection. Inside the loop, it sets the display style property of each tab to "none", effectively hiding all of them. This loop is used to hide all tabs before showing the one specified by tabIndex.

4. tabs[tabIndex].style.display = "block"; : After hiding all tabs, this line makes the tab at the index specified by tabIndex visible by setting its display style property to "block". This effectively displays the selected tab.

5. var buttons = document.getElementsByClassName("tab-button"); : This line selects all elements with the class name "tab-button" from the HTML document and stores them in the buttons variable. These elements are typically the buttons or links that allow users to switch between tabs.

6. for (var i = 0; i < buttons.length; i++) { ... } : Similar to the first loop, this is a for loop that iterates through all the elements in the buttons collection. Inside the loop, it removes the "active-tab-button" class from each button. This class is often used to visually indicate which tab is currently active.

7. buttons[tabIndex].classList.add("active-tab-button"); : Finally, after removing the "active-tab-button" class from all buttons, this line adds the "active-tab-button" class to the button at the index specified by tabIndex. This step highlights the button corresponding to the currently active tab, providing a visual indication of which tab is selected.

Create a JavaScript file with the name script.js and paste the given codes into your JavaScript file and make sure it's linked properly to your HTML document so that the scripts are executed on the page. Remember, you’ve to create a file with .js extension.

Final Output:

See the Pen Toggleable Tabs by Faraz ( @codewithfaraz ) on CodePen .

Creating Elegant Neumorphic Buttons using HTML and CSS (Source Code).jpg

Conclusion:

Congratulations! You've successfully created toggleable tabs for your website using HTML, CSS, and JavaScript. Experiment with different styles and functionalities to suit your project's needs. These tabs not only enhance user experience but also add a professional touch to your web development skills. Happy coding!

Incorporate these tips and techniques into your web projects to create engaging and user-friendly tabbed content. By combining HTML, CSS, and JavaScript, you can take your website's user interface to the next level. Start experimenting with toggleable tabs today!

That’s a wrap!

I hope you enjoyed this post. Now, with these examples, you can create your own amazing page.

Did you like it? Let me know in the comments below 🔥 and you can support me by buying me a coffee.

And don’t forget to sign up to our email newsletter so you can get useful content like this sent right to your inbox!

Thanks! Faraz 😊

Subscribe to my Newsletter

Get the latest posts delivered right to your inbox, latest post.

Create Fortnite Buttons Using HTML and CSS - Step-by-Step Guide

Create Fortnite Buttons Using HTML and CSS - Step-by-Step Guide

Learn how to create Fortnite-style buttons using HTML and CSS. This step-by-step guide includes source code and customization tips.

Create Star Rating using HTML and Bootstrap (Source Code) - Easy Guide

Create Star Rating using HTML and Bootstrap (Source Code) - Easy Guide

June 03, 2024

Creating an Engaging Author Bio Block with Avatar: HTML & Tailwind Guide

Creating an Engaging Author Bio Block with Avatar: HTML & Tailwind Guide

June 02, 2024

Create a Simple Datepicker with Tailwind CSS and HTML

Create a Simple Datepicker with Tailwind CSS and HTML

May 29, 2024

Create a Dashboard with Sliders and Music Player using HTML, CSS, and JavaScript

Create a Dashboard with Sliders and Music Player using HTML, CSS, and JavaScript

May 21, 2024

How to Create a Scroll Down Button: HTML, CSS, JavaScript Tutorial

How to Create a Scroll Down Button: HTML, CSS, JavaScript Tutorial

March 17, 2024

How to Create a Trending Animated Button Using HTML and CSS

How to Create a Trending Animated Button Using HTML and CSS

March 15, 2024

Create Interactive Booking Button with mask-image using HTML and CSS (Source Code)

Create Interactive Booking Button with mask-image using HTML and CSS (Source Code)

March 10, 2024

Create Shimmering Effect Button: HTML & CSS Tutorial (Source Code)

Create Shimmering Effect Button: HTML & CSS Tutorial (Source Code)

March 07, 2024

Create Your Own Bubble Shooter Game with HTML and JavaScript

Create Your Own Bubble Shooter Game with HTML and JavaScript

Learn how to develop a bubble shooter game using HTML and JavaScript with our easy-to-follow tutorial. Perfect for beginners in game development.

Build a Number Guessing Game using HTML, CSS, and JavaScript | Source Code

Build a Number Guessing Game using HTML, CSS, and JavaScript | Source Code

April 01, 2024

Building a Fruit Slicer Game with HTML, CSS, and JavaScript (Source Code)

Building a Fruit Slicer Game with HTML, CSS, and JavaScript (Source Code)

December 25, 2023

Create Connect Four Game Using HTML, CSS, and JavaScript (Source Code)

Create Connect Four Game Using HTML, CSS, and JavaScript (Source Code)

December 07, 2023

Creating a Candy Crush Clone: HTML, CSS, and JavaScript Tutorial (Source Code)

Creating a Candy Crush Clone: HTML, CSS, and JavaScript Tutorial (Source Code)

November 17, 2023

Create Image Color Extractor Tool using HTML, CSS, JavaScript, and Vibrant.js

Create Image Color Extractor Tool using HTML, CSS, JavaScript, and Vibrant.js

Master the art of color picking with Vibrant.js. This tutorial guides you through building a custom color extractor tool using HTML, CSS, and JavaScript.

Build a Responsive Screen Distance Measure with HTML, CSS, and JavaScript

Build a Responsive Screen Distance Measure with HTML, CSS, and JavaScript

January 04, 2024

Crafting Custom Alarm and Clock Interfaces using HTML, CSS, and JavaScript

Crafting Custom Alarm and Clock Interfaces using HTML, CSS, and JavaScript

November 30, 2023

Detect User's Browser, Screen Resolution, OS, and More with JavaScript using UAParser.js Library

Detect User's Browser, Screen Resolution, OS, and More with JavaScript using UAParser.js Library

October 30, 2023

URL Keeper with HTML, CSS, and JavaScript (Source Code)

URL Keeper with HTML, CSS, and JavaScript (Source Code)

October 26, 2023

Creating a Responsive Footer with Tailwind CSS (Source Code)

Creating a Responsive Footer with Tailwind CSS (Source Code)

Learn how to design a modern footer for your website using Tailwind CSS with our detailed tutorial. Perfect for beginners in web development.

Crafting a Responsive HTML and CSS Footer (Source Code)

Crafting a Responsive HTML and CSS Footer (Source Code)

November 11, 2023

Create an Animated Footer with HTML and CSS (Source Code)

Create an Animated Footer with HTML and CSS (Source Code)

October 17, 2023

Bootstrap Footer Template for Every Website Style

Bootstrap Footer Template for Every Website Style

March 08, 2023

How to Create a Responsive Footer for Your Website with Bootstrap 5

How to Create a Responsive Footer for Your Website with Bootstrap 5

August 19, 2022

How to create tabs with HTML, CSS, and JavaScript

JavaScript Course With Certification: Unlocking the Power of JavaScript

CSS tabs are navigation elements that are used to link users to more content on the website. It enhances the user experience on the webpage by letting them switch between information and content. Any browser is the best example of multiple tabs, though tabs in websites are quite a bit different from browser tabs.

Pre-requisites

  • Javascript functions
  • Animations in CSS
  • How to Link JavaScript to HTML?

Creating the Togglable tabs

Digital togglable css tabs are like physical binders. They are used to show multiple parts of the same topic in a single frame. Let us now see how we can create a toggleable tab using HTML, CSS, and JavaScript as shown above. For simplicity, we can include all the codes in a single file using <style> and <script> tags. Any tab will be consisting of the title which will be displayed all the time and the content which needs to be displayed as per the user selection.

The webpage as shown above will be consisting of two tabs, football, and basketball. These tabs will present pictures of respected sports. We are going to implement tabs using a bootstrap navigation bar and tabs. It is possible to implement tabs without bootstrap as well using HTML buttons and CSS.

We will first create the title part of the tab which is consistent and the user can click on them to switch the tab content . Next, we will write content for each tab.

how to create html new tab

In the code above, we are first creating two navigation items using the class nav-item inside nav nav-tabs . These items contain links that are calling the JavaScript function showImages() along with the name of the item selected.

In the later section, a few images for both sports are added using the row and column structure of bootstrap that defines the number of images one single row can have.

Note: class for both the sports i.e. Football and Basketball is the same but their id is different and the id is used to pass to the function showImages() .

We will be using css for tabcontent and the img class.

Add JavaScript

JavaScript is mainly used to show the content according to the tab selected. This code is going to be the same for all the examples below. A minor change will be in the name of the function only.

More exciting examples of Interactive CSS Tabs

The above example was a simple one and many improvements can be brought only using CSS and JavaScript.

Create Toggleable CSS Tabs

Each button in the above code belongs to the class tablinks, and each content part belongs to the class tabcontent. We are calling JavaScript function colorPage() .

CSS In all three tabs, their id is different so we can set the background color for each id. We will be defining CSS properties for tabcontent and tab button to beautify them.

JavaScript code first takes all the available unique tabs. It then hides them all and shows content for the one selected. It also sets the selected button to an active state.

Show a tab by default

As in all the examples we have seen so far, in the beginning, none of the content is shown. But when we visit professional websites, there is always a default tab that is displayed. We can also decide on a default tab to display using JavaScript.

how to create html new tab

The above JavaScript code is run each time a user refreshes or loads a page. Default tabs id is to be passed to getElementById() and set its display to block . Initially display for tabcontent is none in the CSS code thus all the item's display is none. Now JavaScript code changes the default display to block. Later user can switch to any tab.

Glowing Tabs

We will be creating glowing CSS tabs giving a shadow effect to the border of the buttons we are using to represent the tab. The selected tab will be highlighted using the glowing effect using CSS.

We will be adding CSS, HTML, and JavaScript code in the same file. HTML will describe the content and the title. CSS will give the glowing effect using the shadow property and JavaScript will let us switch between tabs. We are taking the example of different types of trees in programming. Four tabs contain four diffenet trees and their key points.

In CSS styles, the shadow effect is used only for the tab that is focused. Shadow defines various properties like position, opacity, shadow length, etc. HTML and JavaScript perform their respective functions. The list is used in HTML to display information about each tree in the content section of the tabs.

Fade in Tabs

The tabcontent class has an animation that links to the fadeEffect keyframe. Keyframes define how the given item will change from one set of CSS styles to another gradually. In animation, time is also mentioned which denotes how much time it should complete the transition.

Close a tab

We can also let users close all the tabs on the webpage. This can be done with the help of JavaScript and HTML. CSS code will be the same.

In each tab content, we are supposed to define a close link. Each of the close links modifies the display of tabcontent class to none , or in simple words hides all the content. CSS code is used to place the close symbol at the top right corner.

Navigation CSS tabs let the user navigate through the entire website from a single place. Let us see an interesting example of a shopping website where we will be using svg icons as tabs.

In the example above, the font we have used is "Raleway" for all the tabs, their titles, and content which is imported from google fonts.

Next, we are using CSS to place the buttons in the right position and make them perform actions when they are clicked or hovered.

All the buttons are of the same class tablinks and we call shopping functions with their respective ids. Each button is not assigned any text, instead, an SVG file is used. This SVG file acts as an icon.

Each of the icons when selected presents a title and its description.

JavaScript code defines the default tab and provides switching between tabs to the users.

  • CSS tabs on the webpage can be created using CSS and HTML. To provide switching between tabs JavaScript is a must.
  • In HTML, the title of the tabs i.e. constants on the webpage, and the content which is unique for each tab which is a variable are to be defined.
  • All the tab titles are either links or buttons. They must belong to the same class but call JavaScript with the id respective to their content.
  • Each content tab must belong to the same class but their ids should be uniqur=e. This id is to be passed to the JavaScript function in the title section.
  • JavaScript defines a function for displaying the default tab, closing all tabs, or switching between tabs.
  • For switching, it first creates an array of all the ids of the class. It then removes all the content. After that, it removes the active from the previously active element. Now it sets the display of the passed id as block and adds active to it.
  • CSS is used for positions, fonts, and animation like fade-in tabs or glowing tabs.

Services & Software

how to create html new tab

Get Microsoft's upgraded Pro OS for a small fraction of the regular price, but only while the sale lasts.

how to create html new tab

Our Top Picks

From VPNs to playlists for your pup, here’re all the best services and software of 2023.

how to create html new tab

Latest Stories

We help you decide which services to keep, try or cancel.

how to create html new tab

Today's NYT Connections Hints and Answers: Help for June 7, #362

how to create html new tab

Today's Wordle Hints and Answer: Help for June 7, #1084

how to create html new tab

NBA Finals 2024: How to Watch, Stream Mavericks vs. Celtics Game 1 Tonight on ABC

how to create html new tab

How to Watch Love Island UK: Stream Season 11 Anywhere for Free

how to create html new tab

Netflix's TikTok Doc: The Unsettling Reality Behind 'Dancing for the Devil'

how to create html new tab

Humane Warns Its AI Pin Charging Case Is a Fire Hazard

how to create html new tab

Microsoft's AI Recall Feature May Not Even Hit Your PC, but Here's How to Disable It

how to create html new tab

When to Watch 'Hit Man' With Glen Powell on Netflix

how to create html new tab

Netflix Is Testing a New Layout Design for TVs

how to create html new tab

18 Best TV Shows on Netflix to Watch Right Now

Purdue Online Writing Lab Purdue OWL® College of Liberal Arts

Welcome to the Purdue Online Writing Lab

OWL logo

Welcome to the Purdue OWL

This page is brought to you by the OWL at Purdue University. When printing this page, you must include the entire legal notice.

Copyright ©1995-2018 by The Writing Lab & The OWL at Purdue and Purdue University. All rights reserved. This material may not be published, reproduced, broadcast, rewritten, or redistributed without permission. Use of this site constitutes acceptance of our terms and conditions of fair use.

The Online Writing Lab at Purdue University houses writing resources and instructional material, and we provide these as a free service of the Writing Lab at Purdue. Students, members of the community, and users worldwide will find information to assist with many writing projects. Teachers and trainers may use this material for in-class and out-of-class instruction.

The Purdue On-Campus Writing Lab and Purdue Online Writing Lab assist clients in their development as writers—no matter what their skill level—with on-campus consultations, online participation, and community engagement. The Purdue Writing Lab serves the Purdue, West Lafayette, campus and coordinates with local literacy initiatives. The Purdue OWL offers global support through online reference materials and services.

A Message From the Assistant Director of Content Development 

The Purdue OWL® is committed to supporting  students, instructors, and writers by offering a wide range of resources that are developed and revised with them in mind. To do this, the OWL team is always exploring possibilties for a better design, allowing accessibility and user experience to guide our process. As the OWL undergoes some changes, we welcome your feedback and suggestions by email at any time.

Please don't hesitate to contact us via our contact page  if you have any questions or comments.

All the best,

Social Media

Facebook twitter.

  • Skip to content
  • Skip to search
  • Skip to footer

Support & Downloads

  • Worldwide - English
  • Arabic - عربي
  • Brazil - Português
  • Canada - Français
  • China - 简体中文
  • China - 繁體中文 (臺灣)
  • Germany - Deutsch
  • Italy - Italiano
  • Japan - 日本語
  • Korea - 한국어
  • Latin America - Español
  • Netherlands - Nederlands">Netherlands - Nederlands
  • Helpful Links
  • Licensing Support
  • Technology Support
  • Support for Cisco Acquisitions
  • Support Tools
  • Cisco Community

how to create html new tab

To open or view a case, you need a service contract

Get instant updates on your TAC Case and more

Login Required

Contact TAC by Phone

800-553-2447 US/Canada

866-606-1866 US/Canada

  • Returns Portal

Products by Category

  • Unified Communications
  • Networking Software (IOS & NX-OS)
  • Collaboration Endpoints and Phones

Status Tools

The Cisco Security portal provides actionable intelligence for security threats and vulnerabilities in Cisco products and services and third-party products.

Get to know any significant issues, other than security vulnerability-related issues, that directly involve Cisco products and typically require an upgrade, workaround, or other customer action.

Check the current status of services and components for Cisco's cloud-based Webex, Security and IoT offerings.

The Cisco Support Assistant (formerly TAC Connect Bot) provides a self-service experience for common case inquiries and basic transactions without waiting in a queue.

Suite of tools to assist you in the day to day operations of your Collaboration infrastructure.

The Cisco CLI Analyzer (formerly ASA CLI Analyzer) is a smart SSH client with internal TAC tools and knowledge integrated. It is designed to help troubleshoot and check the overall health of your Cisco supported software.

My Notifications allows an user to subscribe and receive notifications for Cisco Security Advisories, End of Life Announcements, Field Notices, and Software & Bug updates for specific Cisco products and technologies.

More Support

  • Partner Support
  • Small Business Product Support
  • Business Critical Services
  • Customer Experience
  • DevNet Developer Support
  • Cisco Trust Portal

Cisco Communities

Generate and manage PAK-based and other device licenses, including demo licenses.

Track and manage Smart Software Licenses.

Generate and manage licenses from Enterprise Agreements.

Solve common licensing issues on your own.

Software and Downloads

Find software bugs based on product, release and keyword.

View Cisco suggestions for supported products.

Use the Cisco Software Checker to search for Cisco Security Advisories that apply to specific Cisco IOS, IOS XE, NX-OS and NX-OS in ACI Mode software releases.

Get the latest updates, patches and releases of Cisco Software.

how to create html new tab

  • My View My View
  • Following Following
  • Saved Saved

Amazon's robotaxi unit Zoox to begin testing in Austin, Miami

  • Medium Text

Media tour at the assembly line factory of Zoox, a self-driving vehicle owned by Amazon, in Fremont

  • Company Alphabet Inc Follow
  • Company Amazon.com Inc Follow
  • Company General Motors Co Follow

Sign up here.

Reporting by Jaspreet Singh and Zaheer Kachwala in Bengaluru and Abhirup Roy in San Francisco; Editing by Vijay Kishore and Deepa Babington

Our Standards: The Thomson Reuters Trust Principles. New Tab , opens new tab

FILE PHOTO: U.S. President Biden hosts an event for clean cars and trucks at the White House in Washington

Business Chevron

Passersby walk in front of an electric screen displaying Japan's Nikkei share average outside a brokerage in Tokyo

Stock market rally pauses as US jobs data looms

Global stocks hovered at a record high on Friday after the European Central Bank cut interest rates for the first time in five years and traders waited on crucial U.S. monthly jobs data for clues about whether the Federal Reserve would soon follow.

Reuters logo

IMAGES

  1. The HTML Tab

    how to create html new tab

  2. Build Tabs Using HTML/CSS In Only 12 Minutes

    how to create html new tab

  3. How To Create Tab using HTML & CSS

    how to create html new tab

  4. HTML New Tab for Chrome

    how to create html new tab

  5. How to Create Tabs using HTML, CSS and JavaScript || Very Easy

    how to create html new tab

  6. How to Create Tabs with only HTML & CSS

    how to create html new tab

VIDEO

  1. Learn HTML in Arabic 2023

  2. How to Insert Links on Webpage

  3. How to create a new tab (Easy)

  4. Learn HTML in Arabic 2023

  5. How to create tabs using Html Css and Javascript

  6. How to Add a New Tab in Microsoft Excel

COMMENTS

  1. How to Use HTML to Open a Link in a New Tab

    To create a link on a web page, you need to wrap an anchor (<a>) element around text, then set its href attribute to the URL you want to link to. ... It's easy to use HTML to open a link in a new tab. You just need an anchor (<a>) element with three important attributes:

  2. How To Create Tabs

    Learn how to create tabs in HTML and JavaScript with the W3Schools How To guide. Tabs are useful for organizing and displaying content in a compact and user-friendly way. You will also learn how to style tabs with CSS and use the target attribute to open links in different windows or tabs.

  3. How to Add Tabs in HTML: A Step-by-Step Guide for Beginners

    By mixing HTML, CSS, and JavaScript like this, you can create functional tabs despite HTML's limitations. Remember to play around with different styles and features to make your tabs truly unique! Troubleshooting Common Issues While Adding Tabs. When diving into the world of HTML, adding tabs can sometimes feel like a daunting task.

  4. How to open link in a new tab in HTML?

    I'm not sure why they call it a frame instead of a tab or window. For me, a name of NL creates a new tab every time. Some of the comments (and other sources) say that using the same name will use the same tab. That is what I wanted, but instead, each click creates another new tab instead of changing the contents of the first one. -

  5. HTML Links Hyperlinks

    HTML links are the foundation of web navigation. They allow you to connect different pages and resources on the web. In this tutorial, you will learn how to create and style HTML links with different attributes and values. You will also find examples and exercises to practice your skills.

  6. How to Open a Link in a New Tab

    How to Open a Link in a New Tab - HTML target blank Attribute Explained Jessica Wilkins There will be times where you will want your user to click on a website link and have it open in a new browser tab.

  7. How to Open Links in a New Tab Using HTML and JavaScript

    In your HTML file, locate the link you want to open in a new tab and add the target attribute to it. Set the "target" attribute to "_blank," and this will instruct the browser to open the link in a new tab. If you want to enhance the user experience further or have more control over link behavior, you can use JavaScript.

  8. Creating Tabs in HTML: A Simple Guide (sample code included)

    Tabs are a popular user interface element that allows you to organize content efficiently, presenting it in a neat and accessible way. In this article, we'll explore how to create tabs using a combination of HTML, CSS, and JavaScript. Follow along for a step-by-step guide and enhance your web page's user experience.

  9. How to Make Links Open in a New Window or Tab

    Do you want to create links that open in a new window or tab on your website? This tutorial shows you how to use HTML code to achieve this effect, and explains the pros and cons of this method. Learn from thesitewizard.com, a website that offers free guides and tips on web design, domain name registration, and more.

  10. How To Create Tabs Using HTML , CSS & JavaScript (Day 02)

    To build these tabs, we need HTML, CSS and J... Hello everyone, welcome to yet another exciting tutorial. In today's tutorial, we will learn how to create tabs.

  11. How to Open Hyperlink in a New Window

    Let's see one more example, where besides the target attribute, we also add a rel attribute with the "noopener noreferrer" value. The rel attribute is not mandatory, but it's recommended as a security measure.. Example of opening a link in a new tab with the target and rel attributes:

  12. How To Create Full Page Tabs

    Learn how to create full page tabs with JavaScript and CSS. Full page tabs are useful for organizing large amounts of content on a single page. You can also check out other examples of tabs on W3Schools, such as vertical tabs, toggleable tabs, and fade-in tabs.

  13. How to Open a Link in a New Tab Using HTML

    When we want to direct a user to a third-party web page, the default behavior is for the link to go directly to that page in the same tab. You can keep users on your page by opening up the third-party external link in a new tab so your page is easy to navigate back to. This article covers how to do that. Syntax

  14. How to create a link that opens a new web page window or tab

    How to create an HTML link on a web page. How to create links to sections on the same page in HTML. Open link in new window or tab. See our hyperlink, tab, and window definitions for related links and information. HTML and web design help and support.

  15. How to Create Tabs with HTML

    1. Create a folder. To start, create a folder that will contain the files for your site. Then, create empty .html, .css, and .js files inside. The file names can be anything you want them to be, but keep the file extensions (.html, .css, .js) the same as shown above; otherwise, this will not work. 2. Set up the HTML.

  16. How to Create Tabs with only HTML & CSS

    In this video you will learn how to create tabs with simple HTML and CSS. You don't need Javascript or any other library.Get the code here: https://gist.gith...

  17. How to Create Tabs with HTML, CSS, and JavaScript (Part 1 of 2

    Creating tabs with JavaScript, HTML, and CSS introduces several challenges. 1. It's crucial that components like tabs are accessible, so we'll spend a lot of...

  18. Creating Toggleable Tabs with HTML, CSS, and JavaScript

    Step 2 (CSS Code): Once the basic HTML structure of the toggleable tabs is in place, the next step is to add styling to the tabs using CSS. Next, we will create our CSS file. In this file, we will use some basic CSS rules to create our tabs. Let's break down each part of the code: 1. body:

  19. How to create tabs with HTML, CSS, and JavaScript

    Add HTML. We will first create the title part of the tab which is consistent and the user can click on them to switch the tab content. Next, we will write content for each tab. In the code above, we are first creating two navigation items using the class nav-item inside nav nav-tabs. These items contain links that are calling the JavaScript ...

  20. We have a script in non auto generated HTML for creating a work object

    OpenSpan Robotics - Working with PDF that opens in new tab. Question Solved. To delete a Work Object having a specific pyID and re-use that pyID to create a new work object. Question. I'm using the below code in non auto generated HTML but it opens the new work in new window and not inside the portal. Question. Flow - Create New Work Object

  21. Services & Software

    All the news and tips you need to get the most out of the services, apps and software you use every day.

  22. Welcome to the Purdue Online Writing Lab

    Mission. The Purdue On-Campus Writing Lab and Purdue Online Writing Lab assist clients in their development as writers—no matter what their skill level—with on-campus consultations, online participation, and community engagement. The Purdue Writing Lab serves the Purdue, West Lafayette, campus and coordinates with local literacy initiatives.

  23. How To Start A Business In 11 Steps (2024 Guide)

    The best way to accomplish any business or personal goal is to write out every possible step it takes to achieve the goal. Then, order those steps by what needs to happen first. Some steps may ...

  24. Support

    Check the current status of services and components for Cisco's cloud-based Webex, Security and IoT offerings. Cisco Support Assistant. The Cisco Support Assistant (formerly TAC Connect Bot) provides a self-service experience for common case inquiries and basic transactions without waiting in a queue.

  25. HTML: how to force links to open in a new tab, not new window

    a { target-name: new; target-new: tab; } The target-new property specifies whether new destination links should open in a new window or in a new tab of an existing window. Note: The target-new property only works if the target-name property creates a new tab or a new window.

  26. Nextiva Contact Center: Prompts

    Create and upload new prompts, including viewing and listening to existing prompts. Creating a New Prompt Search for the Prompt icon in the Options Menu. Click Plus (+) to the right of the Search field. Enter the required information under each tab. Information Tab Field Name Description Name This is the name of the prompt.

  27. US solar projects could boom amid deadline to use up tax-exempt panel

    A two-year U.S. tariff holiday on solar panels from Southeast Asia expires on Thursday, starting the clock ticking for American project developers to use the huge amount of equipment they ...

  28. New York set to restrict social media algorithms for teens, WSJ reports

    , opens new tab Facebook and Instagram for fueling mental health crisis among the youth. The legislation is aimed at preventing social media companies from serving automated feeds to minors, the ...

  29. Amazon's robotaxi unit Zoox to begin testing in Austin, Miami

    , opens new tab robotaxi unit Zoox said on Wednesday it plans to start testing its autonomous vehicles in Austin, Texas, and Miami, a move that would mark its first trial sites outside the western ...

  30. html

    From the link: _blank Opens the linked document in a new window or tab. _self Opens the linked document in the same frame as it was clicked (this is default) _parent Opens the linked document in the parent frame. _top Opens the linked document in the full body of the window. framename Opens the linked document in a named frame.