IELTS Mock Test India: Ultimate Guide & Practice (2025) | IELTS Training Camp
{
"@context": "http://schema.org",
"@type": "Article",
"headline": "IELTS Mock Test India: The Ultimate Guide to Effective Practice (2025 Edition)",
"image": "https://ieltstrainingcamp.com/wp-content/uploads/2026/01/8c3fa-chatgpt-image-may-24-2025-10_36_13-pm.png",
"author": {
"@type": "Person",
"name": "Sahil Sayed"
},
"publisher": {
"@type": "Organization",
"name": "IELTS Training Camp",
"logo": {
"@type": "ImageObject",
"url": "https://placehold.co/600x60/000/FFF?text=IELTS+Training+Camp+Logo"
}
},
"datePublished": "2025-07-23",
"dateModified": "2025-07-23",
"description": "A comprehensive guide for Indian students on using IELTS mock tests effectively for practice. Learn how Preptical's simulated exams can help you achieve your target band score for study or immigration in 2025.",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://ieltstrainingcamp.com/ielts-preparation-in-india/mock-tests-and-quizzes/ielts-mock-test/"
},
"keywords": "IELTS mock test India, IELTS practice test India, IELTS full length test India, IELTS simulated exam India, IELTS practice online India, IELTS preparation India, IELTS band score India, Preptical IELTS India, IELTS mock test 2025, IELTS practice questions, IELTS exam format, IELTS time management, best IELTS mock test India, IELTS coaching India"
}
{
"@context": "http://schema.org",
"@type": "FAQPage",
"mainEntity": [
{
"@type": "Question",
"name": "What is an IELTS mock test and why is it important for Indian students?",
"acceptedAnswer": {
"@type": "Answer",
"text": "An
IELTS mock test is a full-length simulated IELTS exam that mirrors the real test's format, question types, and time limits. For Indian students aiming for international education or immigration, it's crucial for familiarizing with the exam structure, practicing time management, identifying weak areas, and building confidence to secure the required band score. Preptical offers excellent mock tests tailored for effective practice."
}
},
{
"@type": "Question",
"name": "How often should Indian students take IELTS mock tests?",
"acceptedAnswer": {
"@type": "Answer",
"text": "The frequency depends on your current proficiency and exam date. Beginners might start with one per week, gradually increasing to 2-3 per week closer to the exam. Regular practice with
IELTS practice tests, especially those designed for Indian test-takers, is key to consistent improvement."
}
},
{
"@type": "Question",
"name": "Where can Indian students find reliable IELTS mock tests?",
"acceptedAnswer": {
"@type": "Answer",
"text": "For the most reliable and effective
IELTS mock test experience in India, we highly recommend
Preptical. Their platform offers full-length simulated exams that accurately replicate the real test environment, making them ideal for students across India."
}
},
{
"@type": "Question",
"name": "How do I review my IELTS mock test results effectively for Indian context?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Beyond just getting a score, analyze your mistakes. For Listening and Reading, identify why your answers were wrong. For Writing and Speaking, seek feedback from experienced tutors (like those available through Preptical's courses) to understand areas for improvement. Indian students often benefit from specific feedback on common pronunciation or grammatical errors prevalent in their region."
}
},
{
"@type": "Question",
"name": "Are IELTS mock tests available for both Academic and General Training in India?",
"acceptedAnswer": {
"@type": "Answer",
"text": "Yes, reputable providers like Preptical offer
IELTS mock tests tailored for both the Academic and General Training modules, ensuring your practice is relevant to your specific exam type, whether you're applying for university or immigration from India."
}
}
]
}
/* Import Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700&display=swap');
/* Global Styling & Reset (IELTS Training Camp Branding) */
body {
font-family: 'Inter', sans-serif; /* Using brand font */
line-height: 1.6;
color: #333;
margin: 0;
padding: 0;
background-color: #f8f8f8; /* Light background */
overflow-x: hidden;
}
/* Main Container */
.container {
max-width: 1200px;
margin: 20px auto;
background-color: #fff;
padding: 25px;
border-radius: 12px; /* Rounded corners */
box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); /* Subtle shadow */
display: flex;
flex-wrap: wrap;
}
/* Table of Contents (TOC) Sidebar */
.toc-sidebar {
flex: 0 0 280px;
margin-right: 30px;
padding: 20px 0;
position: sticky;
top: 100px; /* Adjusted to typically clear header */
height: fit-content;
background-color: #f5f5f1; /* Brand light background */
border-radius: 12px; /* Rounded corners */
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
overflow-y: auto;
max-height: calc(100vh - 120px); /* Adjusted max height */
}
.toc-sidebar h3 {
color: #000; /* Brand black */
margin-top: 0;
padding: 0 20px;
font-size: 1.3em;
border-bottom: 1px solid #dcdcdc;
padding-bottom: 10px;
margin-bottom: 15px;
font-weight: 700;
}
.toc-sidebar ul {
list-style: none;
padding: 0 20px;
margin: 0;
}
.toc-sidebar ul li {
margin-bottom: 10px;
}
.toc-sidebar ul li a {
text-decoration: none;
color: #333;
font-weight: 500;
display: block;
padding: 8px 10px;
border-radius: 8px; /* Rounded corners */
transition: background-color 0.3s ease, color 0.3s ease;
}
.toc-sidebar ul li a:hover,
.toc-sidebar ul li a.active {
background-color: #FBC462; /* Brand yellow/gold */
color: #000; /* Brand black */
}
/* Main Content Area */
.main-content {
flex: 1;
min-width: 0;
}
.main-content h1 {
color: #000; /* Brand black */
font-size: 2.8em; /* Consistent with previous pages */
margin-bottom: 20px;
text-align: center;
border-bottom: 2px solid #FBC462; /* Brand yellow/gold underline */
padding-bottom: 10px;
font-weight: 700;
}
.main-content h2 {
color: #333; /* Dark grey for subheadings */
font-size: 2.2em; /* Consistent with previous pages */
margin-top: 60px;
margin-bottom: 25px;
border-left: 4px solid #FBC462; /* Brand yellow/gold left border */
padding-left: 15px;
font-weight: 700;
}
.main-content h3 {
color: #444; /* Slightly lighter grey */
font-size: 1.6em; /* Consistent with previous pages */
margin-top: 30px;
margin-bottom: 15px;
font-weight: 700;
}
.main-content p {
margin-bottom: 15px;
text-align: justify;
font-weight: 400;
}
.main-content ul, .main-content ol {
margin-left: 25px;
margin-bottom: 15px;
font-weight: 400;
}
.main-content ul li, .main-content ol li {
margin-bottom: 8px;
}
.main-content a {
color: #000; /* Brand black for links */
text-decoration: underline;
transition: color 0.3s ease;
}
.main-content a:hover {
color: #FBC462; /* Brand yellow/gold on hover */
text-decoration: none;
}
/* Info Box Styling */
.info-box {
background-color: #FFF8E1; /* Lighter shade of brand yellow */
border-left: 5px solid #FBC462; /* Brand yellow/gold border */
padding: 15px 20px;
margin: 20px 0;
border-radius: 10px; /* Rounded corners */
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
.info-box p {
margin: 0;
color: #333; /* Dark text */
}
/* Call to Action Box for Affiliate Links */
.affiliate-cta-box {
background-color: #E6F7FF; /* Light blue, inviting */
border: 2px solid #2b7ffe; /* Blue border */
border-radius: 12px;
padding: 25px;
margin: 40px 0;
text-align: center;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
.affiliate-cta-box h3 {
color: #000;
font-size: 1.8em;
margin-top: 0;
margin-bottom: 15px;
}
.affiliate-cta-box p {
font-size: 1.1em;
margin-bottom: 20px;
color: #333;
}
.affiliate-cta-box .cta-button {
display: inline-block;
background-color: #FBC462; /* Brand yellow/gold */
color: #000; /* Brand black */
padding: 15px 30px;
border-radius: 10px;
text-decoration: none;
font-weight: 700;
font-size: 1.1em;
transition: background-color 0.3s ease, transform 0.2s ease, box-shadow 0.3s ease;
border: none;
cursor: pointer;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}
.affiliate-cta-box .cta-button:hover {
background-color: #FFD700; /* Slightly brighter yellow on hover */
transform: translateY(-3px);
box-shadow: 0 6px 15px rgba(0, 0, 0, 0.3);
}
/* Preptical Specific Styling */
.preptical-logo {
max-width: 250px;
height: auto;
margin-bottom: 20px;
}
.preptical-review-box {
background-color: #e0f2f7; /* Light blue for review */
border: 2px solid #2b7ffe;
border-radius: 12px;
padding: 25px;
margin: 40px 0;
text-align: center;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}
.preptical-review-box h3 {
color: #000;
font-size: 1.8em;
margin-top: 0;
margin-bottom: 15px;
}
.preptical-review-box p {
font-size: 1.1em;
margin-bottom: 20px;
color: #333;
}
.preptical-review-box .review-stars {
color: #FFD700; /* Gold stars */
font-size: 1.5em;
margin-bottom: 10px;
}
/* Image Styling */
.content-image {
max-width: 100%;
height: auto;
border-radius: 10px;
margin: 25px 0;
box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
display: block;
margin-left: auto;
margin-right: auto;
}
/* Responsive Carousel */
.carousel-container {
margin-top: 40px;
overflow: hidden;
padding: 40px 30px;
background-color: #f5f5f1;
border-radius: 12px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
position: relative;
}
.carousel-title {
text-align: center;
color: #000;
margin-bottom: 25px;
font-size: 1.8em;
font-weight: 700;
}
.carousel-wrapper {
display: flex;
justify-content: flex-start;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
padding: 0 10px;
scroll-snap-type: x mandatory;
gap: 30px;
}
.carousel-item {
flex: 0 0 auto;
width: 300px;
background-color: #ffffff;
border: 1px solid #ddd;
border-radius: 8px;
padding: 20px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
scroll-snap-align: start;
transition: transform 0.3s ease;
display: flex;
flex-direction: column;
}
.carousel-item:hover {
transform: translateY(-5px);
}
.carousel-item h4 {
color: #000;
margin-top: 0;
font-size: 1.2em;
min-height: 50px;
font-weight: 700;
}
.carousel-item p {
font-size: 0.9em;
color: #555;
min-height: 80px;
flex-grow: 1;
}
.carousel-item a {
display: inline-block;
background-color: #000; /* Brand black button */
color: #fff;
padding: 8px 15px;
border-radius: 8px;
text-decoration: none;
margin-top: 10px;
transition: background-color 0.3s ease;
font-weight: 600;
}
.carousel-item a:hover {
background-color: #FBC462; /* Brand yellow/gold on hover */
color: #000; /* Brand black on hover */
}
/* Responsive Adjustments */
@media (max-width: 992px) {
.container {
flex-direction: column;
margin: 15px auto;
padding: 15px;
}
.toc-sidebar {
position: static;
width: 100%;
margin-right: 0;
margin-bottom: 25px;
max-height: none;
}
.toc-sidebar h3 {
text-align: center;
padding-bottom: 5px;
margin-bottom: 10px;
}
.toc-sidebar ul {
display: flex;
flex-wrap: wrap;
justify-content: center;
padding: 0 10px;
}
.toc-sidebar ul li {
margin: 5px 8px;
}
.toc-sidebar ul li a {
padding: 6px 12px;
font-size: 0.9em;
text-align: center;
}
.main-content {
width: 100%;
}
.main-content h1 {
font-size: 2em;
}
.main-content h2 {
font-size: 1.6em;
}
.main-content h3 {
font-size: 1.3em;
}
.affiliate-cta-box {
padding: 20px;
}
.affiliate-cta-box h3 {
font-size: 1.5em;
}
.affiliate-cta-box p {
font-size: 1em;
}
.affiliate-cta-box .cta-button {
padding: 12px 25px;
font-size: 1em;
}
.preptical-logo {
max-width: 200px;
}
.carousel-item {
width: 280px;
margin: 0 10px;
}
}
@media (max-width: 768px) {
.container {
margin: 10px;
padding: 10px;
}
.main-content h1 {
font-size: 1.8em;
}
.main-content h2 {
font-size: 1.4em;
}
.carousel-wrapper {
flex-wrap: nowrap;
overflow-x: auto;
scroll-snap-type: x mandatory;
}
.carousel-item {
min-width: 85%;
scroll-snap-align: start;
}
}
@media (max-width: 480px) {
.toc-sidebar ul li a {
font-size: 0.85em;
padding: 5px 10px;
}
.carousel-item {
min-width: 95%;
}
}
IELTS Mock Test India: The Ultimate Guide to Effective Practice (2025 Edition)
Preparing for the IELTS exam can be challenging, but a strategic approach will boost your chances of success. For students in India aiming for global opportunities, incorporating regular IELTS mock test practice is absolutely essential. Mock tests are full-length simulated IELTS exams that mirror the real test's format, question types, and time limits. By taking these practice exams under exam-like conditions, you can assess your current proficiency, identify areas for improvement, and build familiarity with the test structure. In essence, IELTS mock tests offer a realistic preview of the actual exam and are invaluable for honing the skills and confidence needed to achieve your target band score for your study abroad or immigration goals.
Overview: Why IELTS Mock Tests Are Crucial for Indian Students
Engaging with IELTS mock tests is more than just casual practice - it's a critical training tool for serious test-takers in India. Given the competitive nature of admissions and visa processes, maximizing your score is paramount. Here's why mock tests are so important for IELTS preparation:
- Familiarity with the Test Format: Mock tests replicate the IELTS exam's structure, question types, and instructions, making you intimately familiar with each section. This familiarity greatly reduces test-day anxiety, since you won't be surprised by the format. Knowing what to expect allows you to approach the exam with a calmer mindset.
- Time Management Skills: The IELTS is a timed exam, and many test-takers, especially those new to standardized tests, struggle to complete sections within the allocated time. Regular practice with a full-length IELTS simulated exam helps you develop crucial time management strategies, ensuring you can complete all tasks efficiently on test day.
- Identifying Weaknesses & Strengths: By taking a comprehensive IELTS practice test, you can pinpoint specific areas where you struggle (e.g., a particular question type in Reading, or certain grammar points in Writing) and areas where you excel. This allows you to tailor your study plan for maximum impact, focusing your efforts where they're most needed.
- Confidence Building: Successfully completing multiple IELTS mock tests under timed conditions builds confidence. The more you practice, the more comfortable you become with the pressure and format, leading to a more relaxed and effective performance on the actual exam. This is especially important for high-stakes tests like the IELTS.
Our Top Recommendation for Indian Students: Preptical for IELTS Mock Tests
★★★★★
At IELTS Training Camp, we consistently recommend Preptical as the premier platform for your IELTS mock test needs, particularly for students in India. Their comprehensive, full-length simulated exams are meticulously designed to replicate the real IELTS experience, from question types and difficulty to strict time limits.
What sets Preptical apart is their commitment to accuracy and their user-friendly interface, making your practice sessions truly effective. They understand the nuances of what Indian students need to succeed. Whether you're aiming for a quick boost or a thorough preparation, Preptical's resources are invaluable. We've seen countless students from across India achieve their target band scores by leveraging Preptical's realistic practice environment and targeted support.
Start Your IELTS Success Path with Preptical!
How to Effectively Use IELTS Mock Tests for Maximum Impact
Simply taking an IELTS mock test isn't enough. To truly benefit, you need a strategic approach to practice:
- Simulated Exam Conditions: Always take your IELTS full length test under strict exam conditions. This means:
- No interruptions from phone calls or family.
- Strict adherence to time limits for each module – use a timer!
- Using only permitted materials (pencil, eraser, answer sheet – no dictionaries or mobile phones).
- Completing Listening, Reading, and Writing in one sitting (2 hours 40 minutes), just like the real exam. This builds stamina.
This helps you build stamina and mental resilience for test day, mimicking the actual pressure.
- Reviewing Results & Seeking Feedback: Don't just look at your score. Analyze your mistakes in depth:
- For Listening and Reading: Understand why your answers were incorrect. Was it a vocabulary issue, misinterpretation of instructions, or a time constraint?
- For Writing and Speaking: This is where expert feedback is invaluable. Consider Preptical's courses which often include detailed feedback on your written and spoken responses. This helps you understand areas for improvement in coherence, cohesion, lexical resource, grammatical range and accuracy, and fluency – critical for improving your band score.
- Focus on Weaknesses: Use your mock test results to identify your weakest areas and dedicate more study time to them. If you consistently struggle with a particular question type, practice it extensively. This targeted approach is far more efficient than generic study.
- Track Progress: Keep a record of your scores and performance on each IELTS practice test. This allows you to see your improvement over time and stay motivated, seeing tangible evidence of your hard work paying off.
Module-Specific Mock Test Tips
Listening Module
- Practice Different Accents: The IELTS Listening test features a variety of native English accents (British, North American, Australian/NZ, etc.). Ensure your IELTS mock test materials expose you to this diversity.
- Note-Taking Skills: Practice efficient note-taking. You won't have time to write everything down, so focus on keywords and key information that will help you answer the questions.
- Transfer Time: Remember the 10-minute transfer time at the end for paper-based tests. Practice transferring your answers accurately within this limit. For computer-delivered IELTS, there is only 2 minutes to review.
Reading Module
- Skimming & Scanning: Practice rapidly skimming texts for the general idea and scanning for specific information. These are vital skills for managing the dense texts in the Reading section.
- Question Types: Familiarize yourself with all Reading question types (e.g., True/False/Not Given, matching headings, summary completion). Preptical's IELTS practice questions cover these extensively, ensuring you're prepared for anything.
- Time Allocation: With 3 passages and 60 minutes, time is critical. Practice allocating roughly 20 minutes per passage, including transferring answers.
Writing Module
- Task 1 & Task 2 Practice: Practice both tasks under timed conditions. Ensure you meet the word count (150 words for Task 1, 250 words for Task 2).
- Structure & Cohesion: Focus on clear paragraphing, logical organization, and using cohesive devices. A well-structured essay is key to a good score.
- Grammar & Vocabulary: Aim for a range of grammatical structures and appropriate vocabulary. Get feedback on these areas from a tutor, as self-correction can be difficult here.
Speaking Module
- Record Yourself: Practice speaking on various topics and record your responses. Listen back to identify areas for improvement in fluency, coherence, pronunciation, and lexical resource.
- Mock Interviews: If possible, practice with a partner or tutor who can simulate the IELTS Speaking interview. Preptical's courses often offer speaking practice with feedback from experienced examiners or tutors.
- Expand on Answers: Avoid one-word answers. Practice extending your responses with examples, explanations, and personal experiences to demonstrate your fluency and vocabulary.
Choosing the Right IELTS Mock Tests for Indian Students
When selecting your IELTS practice online materials, prioritize quality and authenticity. While there are many free resources, investing in a reputable platform like Preptical ensures you're practicing with materials that accurately reflect the real exam and are highly relevant to the Indian test-taking context.
Look for providers that offer:
- Full-length tests for all four modules, mirroring the actual exam.
- Detailed answer keys and explanations for Listening and Reading, helping you learn from your mistakes.
- Opportunities for personalized feedback on Writing and Speaking (often part of paid courses), which is crucial for improvement.
- Content updated for the latest exam format (e.g., 2025 edition), ensuring you're always practicing with current material.
Accelerate Your IELTS Readiness with Preptical in India!
Ready to conquer the IELTS and secure your future abroad? Preptical offers the fastest and most effective way to become IELTS ready through their expertly designed mock tests and comprehensive courses. Don't leave your score to chance – join thousands of successful Indian students who chose Preptical!
Get IELTS Ready in 2 Weeks with Preptical!
FAQs about IELTS Mock Tests for Indian Students
Q: What is an IELTS mock test and why is it important for Indian students?
A: An IELTS mock test is a full-length simulated IELTS exam that mirrors the real test's format, question types, and time limits. For Indian students aiming for international education or immigration, it's crucial for familiarizing with the exam structure, practicing time management, identifying weak areas, and building confidence to secure the required band score. Preptical offers excellent mock tests tailored for effective practice.
Q: How often should Indian students take IELTS mock tests?
A: The frequency depends on your current proficiency and exam date. Beginners might start with one per week, gradually increasing to 2-3 per week closer to the exam. Regular practice with IELTS practice tests, especially those designed for Indian test-takers, is key to consistent improvement.
Q: Where can Indian students find reliable IELTS mock tests?
A: For the most reliable and effective IELTS mock test experience in India, we highly recommend Preptical. Their platform offers full-length simulated exams that accurately replicate the real test environment, making them ideal for students across India.
Q: How do I review my IELTS mock test results effectively for Indian context?
A: Beyond just getting a score, analyze your mistakes. For Listening and Reading, identify why your answers were wrong. For Writing and Speaking, seek feedback from experienced tutors (like those available through Preptical's courses) to understand areas for improvement. Indian students often benefit from specific feedback on common pronunciation or grammatical errors prevalent in their region.
Q: Are IELTS mock tests available for both Academic and General Training in India?
A: Yes, reputable providers like Preptical offer IELTS mock tests tailored for both the Academic and General Training modules, ensuring your practice is relevant to your specific exam type, whether you're applying for university or immigration from India.
Conclusion
Incorporating regular IELTS mock test practice into your study routine is not just an option; it's a necessity for achieving your target band score, especially for Indian students navigating competitive global aspirations. These simulated exams provide invaluable insights into your strengths and weaknesses, help you master time management, and build the confidence you need on test day.
We strongly encourage you to leverage high-quality resources like Preptical's IELTS mock tests to ensure your practice is as effective as possible. With diligent practice and strategic review, you'll be well on your way to IELTS success in 2025 and beyond!
Don't Wait! Become IELTS Ready Faster!
Unlock your full potential with Preptical's proven strategies and comprehensive mock tests. This is the fastest way to become truly IELTS ready and confidently face your exam!
Become IELTS Ready the Fastest Way!
More Essential IELTS Calculators & Tools
Explore All IELTS Tools
Discover our full suite of essential IELTS preparation tools and guides.
See All Tools →
IELTS Listening Score Calculator
Convert your raw Listening score to the official IELTS band score.
Calculate Now →
IELTS Reading Score Calculator
Find your Reading band score for both Academic and General Training.
Calculate Now →
IELTS Writing Band Score Calculator
Understand how your Writing tasks are graded and calculate your band.
Calculate Now →
IELTS Speaking Score Calculator
Estimate your Speaking band based on key assessment criteria.
Calculate Now →
PTE vs. IELTS Score Calculator
Compare your PTE and IELTS scores easily with this conversion tool.
Compare Now →
IELTS to CLB Calculator
Convert your IELTS scores to Canadian Language Benchmark (CLB) levels.
Convert Now →
How to Book IELTS Exam in UK
A step-by-step guide to finding and booking your IELTS test in the UK.
Book Now →
IELTS Preparation in India: Your Complete Guide
Explore comprehensive resources for mastering IELTS in India.
Read More →
IELTS Writing Practice: Strategies for Success
Improve your IELTS Writing skills with expert tips and practice exercises.
Start Practicing →
English Quiz Hub: Test Your Language Skills
Sharpen your English grammar and vocabulary with interactive quizzes.
Take a Quiz →
// Smooth scroll for TOC links
document.querySelectorAll('.toc-sidebar a').forEach(anchor => {
anchor.addEventListener('click', function (e) {
e.preventDefault();
document.querySelector(this.getAttribute('href')).scrollIntoView({
behavior: 'smooth'
});
// Update active class for sidebar links
document.querySelectorAll('.toc-sidebar ul li a').forEach(link => {
link.classList.remove('active');
});
this.classList.add('active');
});
});
// Highlight active TOC link based on scroll position
window.addEventListener('scroll', () => {
const sections = document.querySelectorAll('.main-content h2, .main-content h1, .main-content h3'); // Include h3 for country sections
const navLinks = document.querySelectorAll('.toc-sidebar ul li a');
let current = '';
sections.forEach(section => {
const sectionTop = section.offsetTop;
const sectionHeight = section.clientHeight;
// Adjust offset for better timing, considering sticky header if any
if (pageYOffset >= sectionTop - window.innerHeight / 3) {
current = section.getAttribute('id');
}
});
navLinks.forEach(link => {
link.classList.remove('active');
if (link.getAttribute('href').includes(current)) {
link.classList.add('active');
}
});
});
// Initialize active class on page load if hash exists
window.addEventListener('load', () => {
if (window.location.hash) {
const targetId = window.location.hash;
const targetLink = document.querySelector(`.toc-sidebar a[href="${targetId}"]`);
if (targetLink) {
targetLink.classList.add('active');
// Scroll to target, accounting for sticky header
const targetElement = document.querySelector(targetId);
if (targetElement) {
const headerOffset = 100; // Adjust this if your actual header height is different
const elementPosition = targetElement.getBoundingClientRect().top + window.pageYOffset;
const offsetPosition = elementPosition - headerOffset;
window.scrollTo({
top: offsetPosition,
behavior: "smooth"
});
}
} else {
// If no hash, set the first link as active
const firstLink = document.querySelector('.toc-sidebar ul li a');
if (firstLink) {
firstLink.classList.add('active');
}
}
}
});