Create a page that introduces you as a JavaScript student. This project allows you to display your profile in the browser and print a welcome message to the Console. By completing this task, you will gain practical experience in building a student profile page.
Use the HTML structure from Lesson 1.4 as your starting point. This lesson provides essential guidance on how HTML, CSS, and JavaScript collaborate effectively.
Update the page with:
Keep the main heading as “Student Profile.” This ensures that your page has a clear and specific focus, making it easy for visitors to understand your content.
Next, add this code to style.css:
File: style.css
/* Example CSS code here */
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 32px 16px;
font-family: Arial, sans-serif;
line-height: 1.6;
background-color: #f3f4f6;
color: #1f2937;
}
main {
max-width: 560px;
margin: 0 auto;
padding: 24px;
background-color: #ffffff;
border-top: 6px solid #f7df1e;
border-radius: 12px;
}
h1 {
margin-top: 0;
color: #173b65;
}
p {
margin: 12px 0;
}
This creates a white profile card on a light background, providing a clean look to your profile page. You do not need to memorise these styling rules for now. However, it is important to notice that changing the CSS affects the page’s appearance without altering its content. Therefore, this understanding will help you effectively manage styles in future projects.
Replace the temporary error exercises in script.js with:
File: script.js
// Print welcome messages in the browser console.
console.log("Welcome, Aman Singh!");
console.log("Course: JavaScript Basics");
console.log("My goal is to build useful websites.");
// Print welcome messages in the browser console.
console.log("Welcome, Aman Singh!");
console.log("Course: JavaScript Basics");
console.log("My goal is to build useful websites.");
Make sure to replace the sample name and learning goal with your own. The line starting with // is a comment. It explains the code for readers, but JavaScript does not execute comments as instructions. Therefore, you can use comments to make your code clearer.
Save all three files, open index.html, and refresh the page. You should now see:
Change the first console message to:
File: script.js
console.log("My JavaScript file is connected correctly.");
console.log("My JavaScript file is connected correctly.");
If the new message appears, the browser has successfully loaded and run your updated file. This confirms that your connection works well.
For those looking to further enhance their skills, add a “Favourite subject” paragraph to your student profile page and a matching console message. Then, consider changing the heading color in your CSS to demonstrate your stylistic preferences.