If you're seeing this message, it means we're having trouble loading external resources on our website.

If you're behind a web filter, please make sure that the domains *.kastatic.org and *.kasandbox.org are unblocked.

Main content

Instructions: Profile page

Apply variables, strings, and user input to personalize a profile page using an HTML template.
How do websites customize the same webpage for thousands of different users?
When you open your profile page on a website, you see your name, your bio, your latest posts, and your notifications. But when your friend opens their profile page, they see the same page layout with data specific to them!
The programmers behind these websites achieve this with templating. When a user opens a profile page, the website fetches a template that describes the page’s general layout and then does some quick fill-in-the-blanks with the user’s profile data.
In this project, you’ll personalize a webpage by filling in a template of your own.

HTML basics

The Internet uses the language HTML to describe the layout of a webpage. We’ve built the HTML template for you, so no need to rush off to the nearest HTML tutorial!
The important thing to know is that HTML uses tags to indicate how content should be formatted. Anything with <> brackets is a tag, like <p>, <h1>, or <h2>. There’s an opening tag, like <button> and a closing tag like </button>, and then the actual text to be displayed goes in between.
An HTML element diagram. Angle brackets surround the opening tag, the content goes in the middle, and angle brackets surround the closing tag.
You can think of tags like formatting text in a docs app. You select some text and then a format option like Normal text, Title, Heading 1, or Heading 2, and then that changes the default size and bolding of the text you selected. Tags do the same thing - in fact, the <h1> tag stands for Heading 1!

Rendering HTML strings

Rendering is the process of interpreting the HTML tags and then displaying the formatted result as a webpage - it’s what your web browser does every time you load a new page!
As you work on this project, you’ll want to render and test your HTML string as you go.
  • Run the program.
  • Navigate to the Khan Academy HTML renderer.
  • Copy and paste your printed HTML string into the left panel, between the <body> and </body> tags.
The rendered HTML should show up in the right panel.

Loading user data

Take a look at the provided HTML template and think about what might change on a profile page based on the user.
  • Use the input() function to ask the user for at least three different profile data or settings.
  • Store the result of each input() call in a new variable.
You’ll use the entered data to personalize the HTML template to the user. For example, you might ask the user to enter a bio, username, or email - or maybe you ask what their preferred greeting is, so you can make the header display “Hola” instead of “Hello”.

Filling in the blanks

Now it’s time to fill in the template!
  • Use your new variables to substitute the values entered by the user into the HTML string.
  • Use at least one of the user values in multiple places.
In the code, find the text you want to replace and then concatenate the stored user value into the right place in the string. For example, you might replace all occurrences of the default “guest” with the user’s name.
Remember to only modify the text between the opening and closing HTML tags, not the tags themselves!

More to explore

Add a few new <p> or <h2> elements to your template, or explore the Intro to HTML/CSS unit to discover more types of HTML tags. Add an <a> element to the template and let the user to personalize the link, or add an <img> element to the template and let the user personalize the image size.
Instead of a profile page, re-theme the template as another kind of webpage. Consider how your webpage might be customized to a specific user or use case, and change your questions accordingly.

Want to join the conversation?