-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscriptLern.js
More file actions
3472 lines (3095 loc) Β· 171 KB
/
Copy pathscriptLern.js
File metadata and controls
3472 lines (3095 loc) Β· 171 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ============================================
// APPLICATION STATE & CONFIGURATION
// ============================================
const CONFIG = {
progress: { html: { completed: 0, total: 5 }, css: { completed: 0, total: 5 }, overall: { completed: 0, total: 10 } },
autoRefresh: true,
lineNumbers: true,
currentLesson: 'html-structure',
userScores: {},
version: '3.0.0'
};
const STORAGE_KEY = 'codecraft_user_progress';
// ============================================
// SAVE / LOAD PROGRESS
// ============================================
function saveProgress(username) {
const progressData = {
username,
lastAccessed: new Date().toISOString(),
currentLesson: CONFIG.currentLesson,
scores: CONFIG.userScores,
completedLessons: getCompletedLessons(),
htmlProgress: CONFIG.progress.html,
cssProgress: CONFIG.progress.css,
overallProgress: CONFIG.progress.overall,
version: CONFIG.version
};
const all = getAllProgress();
all[username.toLowerCase()] = progressData;
localStorage.setItem(STORAGE_KEY, JSON.stringify(all));
}
function loadProgress(username) {
const all = getAllProgress();
const data = all[username.toLowerCase()];
if (data) {
CONFIG.currentLesson = data.currentLesson || 'html-structure';
CONFIG.userScores = data.scores || {};
CONFIG.progress.html = data.htmlProgress || { completed: 0, total: 5 };
CONFIG.progress.css = data.cssProgress || { completed: 0, total: 5 };
CONFIG.progress.overall = data.overallProgress || { completed: 0, total: 10 };
restoreCompletedLessons(data.completedLessons || []);
loadLesson(CONFIG.currentLesson);
updateProgress();
showToast(`Welcome back, ${username}! `, 'success');
return true;
}
return false;
}
function getAllProgress() {
const s = localStorage.getItem(STORAGE_KEY);
return s ? JSON.parse(s) : {};
}
function getCompletedLessons() {
const completed = [];
elements.lessonItems.forEach(item => {
if (item.classList.contains('completed')) completed.push(item.dataset.lesson);
});
return completed;
}
function restoreCompletedLessons(list) {
elements.lessonItems.forEach(item => {
if (list.includes(item.dataset.lesson)) {
item.classList.add('completed');
const icon = item.querySelector('.lesson-status i');
if (icon) icon.className = 'fas fa-check-circle';
}
});
}
// ============================================
// LOGIN MODAL
// ============================================
function showLoginModal() {
const savedUser = localStorage.getItem('codecraft_current_user');
if (savedUser && loadProgress(savedUser)) {
addLogoutButton();
return;
}
const users = Object.values(getAllProgress());
let userListHTML = '';
if (users.length > 0) {
userListHTML = '<div class="saved-users"><h4>Continue as:</h4><ul>';
users.forEach(u => {
const pct = Math.round((u.overallProgress.completed / u.overallProgress.total) * 100);
userListHTML += `<li onclick="loadUserProgress('${u.username}')"><strong>${u.username}</strong> β ${pct}% complete</li>`;
});
userListHTML += '</ul></div>';
}
const modal = document.createElement('div');
modal.className = 'login-modal';
modal.innerHTML = `
<div class="login-card">
<h2>Welcome to Code Lab! </h2>
<p>Enter your name to start or continue learning.</p>
${userListHTML}
<form id="login-form">
<input type="text" id="username-input" placeholder="Enter your name" required minlength="2" autocomplete="off"/>
<button type="submit" class="btn btn-primary"><i class="fas fa-sign-in-alt"></i> Start Learning</button>
</form>
</div>`;
document.body.appendChild(modal);
setTimeout(() => document.getElementById('username-input')?.focus(), 300);
document.getElementById('login-form').addEventListener('submit', e => {
e.preventDefault();
const name = document.getElementById('username-input').value.trim();
if (name.length >= 2) {
localStorage.setItem('codecraft_current_user', name);
if (!loadProgress(name)) {
showToast(`Welcome, ${name}! Let's start learning! `, 'success');
loadLesson('html-structure');
}
addLogoutButton();
modal.remove();
}
});
}
window.loadUserProgress = function(username) {
localStorage.setItem('codecraft_current_user', username);
loadProgress(username);
addLogoutButton();
document.querySelector('.login-modal')?.remove();
};
function addLogoutButton() {
if (document.getElementById('logout-btn')) return;
const headerActions = document.querySelector('.header-actions');
const currentUser = localStorage.getItem('codecraft_current_user');
if (currentUser && headerActions) {
const btn = document.createElement('button');
btn.id = 'logout-btn';
btn.className = 'btn btn-outline';
btn.innerHTML = `<i class="fas fa-sign-out-alt"></i> ${currentUser}`;
btn.onclick = () => {
if (confirm(`Save progress for ${currentUser} and logout?`)) {
saveProgress(currentUser);
localStorage.removeItem('codecraft_current_user');
location.reload();
}
};
headerActions.appendChild(btn);
}
}
// ============================================
// LESSONS DATA
// ============================================
const LESSONS = {
// ==========================================
// LESSON 1: HTML Document Structure
// ==========================================
'html-structure': {
title: 'HTML Document Structure',
subtitle: 'Learn the basic building blocks of every web page',
difficulty: 'Beginner',
duration: '15 minutes',
theory: `
<div class="theory-section">
<div class="section-header">
<div class="section-icon"><i class="fas fa-rocket"></i></div>
<h2 class="section-title">Welcome! Do you want to try some easy coding shtaff?</h2>
</div>
<p class="theory-text">Imagine you're writing a letter, but instead of paper, you're writing for a web browser, that's basically what HTML is - a way to tell your browser "hey, this is a title, this is a paragraph, this is important text." The browser reads your instructions and displays everything beautifully on the screen.</p>
<p class="theory-text">Don't worry if this sounds complicated - it's actually much simpler than it seems. By the end of this lesson, you'll get knowledge.</p>
<div class="tip-box">
<div class="note-header">
<div class="note-icon tip-icon"><i class="fas fa-info-circle"></i></div>
<div class="note-title tip-title">Before We Start - Look at the Right Side of Your Screen</div>
</div>
<p class="theory-text">You see two boxes on the right? The top one is your <strong>Code Editor</strong> - this is where you'll type your code. The bottom one is <strong>Preview</strong> - this shows you what your web page looks like in real time. Every time you type something in the editor, the preview updates automatically.</p>
</div>
</div>
<div class="theory-section">
<div class="section-header">
<div class="section-icon"><i class="fas fa-question-circle"></i></div>
<h2 class="section-title">So What Exactly is HTML?</h2>
</div>
<p class="theory-text">HTML stands for <strong>Hyper Text Markup Language</strong>. Sounds scary? Let's break it down:</p>
<p class="theory-text">Think of HTML like the skeleton of a human body. Just like bones give structure to your body, HTML gives structure to a web page. It tells the browser: "This part is the head of the page, this is the body, this text is a big title, this text is just a regular paragraph."</p>
<p class="theory-text">Without HTML, a web page would just be a messy blob of text with no organization. HTML is what makes the internet actually readable and organized.</p>
</div>
<div class="theory-section">
<div class="section-header">
<div class="section-icon"><i class="fas fa-tags"></i></div>
<h2 class="section-title">The Building Blocks: Tags</h2>
</div>
<p class="theory-text">HTML uses something called <strong>tags</strong>. A tag is like a label that tells the browser what kind of content you're creating. Tags always look like this - they have angle brackets (these things: < >) around them.</p>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-code"></i> The Basic Pattern</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><code><name_of_the_tag>Your content goes here</name_of_the_tag></code></pre>
</div>
<p class="theory-text">See how there's an <strong>opening tag</strong> at the beginning and a <strong>closing tag</strong> at the end? The closing tag has a forward slash (/) before the tag name. This is super important - it's like opening and closing a door. You open it, put your content inside, then close it.</p>
<div class="note-box">
<div class="note-header">
<div class="note-icon"><i class="fas fa-lightbulb"></i></div>
<div class="note-title">The Golden Rule</div>
</div>
<p class="theory-text">If you open a tag, you <strong>must</strong> close it. Think of it like parentheses in math - every opening parenthesis needs a closing one. Open with <code><h1></code>, close with <code></h1></code>. Forget to close it? Your page might look broken or weird. This is the #1 mistake beginners make, so always double-check!</p>
</div>
</div>
<div class="theory-section">
<div class="section-header">
<div class="section-icon"><i class="fas fa-heading"></i></div>
<h2 class="section-title">The Four Tags You'll Learn Today</h2>
</div>
<p class="theory-text">We're going to use just four tags today. That's it - four! Let me introduce them:</p>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-list"></i> Meet Your New Friends</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><code><title>Page Title</title></code></pre>
</div>
<p class="theory-text"><strong>The Title Tag:</strong> This is what shows up in your browser tab - you know, that little text at the top of your browser window. It's also what Google shows when your page appears in search results. It's hidden on the actual page, but very important!</p>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-list"></i> The Big Heading</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><code><h1>Main Heading</h1></code></pre>
</div>
<p class="theory-text"><strong>The H1 Tag:</strong> This is your main headline - the biggest, most important text on your page. Think of it like the title of a newspaper article. You should only use ONE h1 per page. It's like having one main title for your story.</p>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-list"></i> The Subheading</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><code><h2>Subheading</h2></code></pre>
</div>
<p class="theory-text"><strong>The H2 Tag:</strong> This is a smaller heading, like a section title. If your page is a book, h1 is the book title and h2 are the chapter titles. You can have as many h2 tags as you want h3, h4, h5...</p>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-list"></i> The Paragraph</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><code><p>This is regular text.</p></code></pre>
</div>
<p class="theory-text"><strong>The P Tag:</strong> P stands for paragraph. This is your regular text - the stuff people actually read. Blog posts, descriptions, explanations - all of that goes inside p tags.</p>
</div>
<div class="theory-section">
<div class="section-header">
<div class="section-icon"><i class="fas fa-eye"></i></div>
<h2 class="section-title">What About All That Other Code in the Editor?</h2>
</div>
<p class="theory-text">If you look at the code editor on the right, you'll see a bunch of code already there. Most of it is just "setup code" that every web page needs. Let me quickly explain what you're seeing:</p>
<p class="theory-text"><code><!DOCTYPE html></code> - This tells the browser "hey, this is an HTML document." Just leave it there.</p>
<p class="theory-text"><code><html></code> - Everything on your page lives inside this tag. It's like the container for everything.</p>
<p class="theory-text"><code><head></code> - This section contains invisible stuff - settings, the title, links to styles. Users don't see this part directly.</p>
<p class="theory-text"><code><body></code> - This is where the main things happens! Everything you want people to SEE on your page goes in the body. This is where you'll be working today.</p>
<div class="tip-box">
<div class="note-header">
<div class="note-icon tip-icon"><i class="fas fa-hand-point-right"></i></div>
<div class="note-title tip-title">Focus Here</div>
</div>
<p class="theory-text">For this lesson, you only need to work inside the <code><body></code> section and change the <code><title></code>. That's it! Ignore everything else for now.</p>
</div>
</div>
<div class="theory-section">
<div class="section-header">
<div class="section-icon"><i class="fas fa-comment-dots"></i></div>
<h2 class="section-title">One More Thing: Comments</h2>
</div>
<p class="theory-text">In the code editor, you'll see lines that look like this:</p>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-code"></i> This is a Comment</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><code><!-- STEP 2: Add your h1 heading below this line --></code></pre>
</div>
<p class="theory-text">These are called <strong>comments</strong>. They're notes for humans - the browser completely ignores them. I've put comments in the code to show you exactly where to type each thing. Think of them like sticky notes saying "write here!"</p>
</div>
<div class="exercise-box">
<div class="exercise-header">
<div class="exercise-icon"><i class="fas fa-pencil-alt"></i></div>
<div class="exercise-title"> Your Task Today: Create an "About Me" Page, very simple!</div>
</div>
<p class="theory-text">Alright, Now You're going to create a simple "About Me" page. Follow these steps exactly, and watch the preview update as you type. Do not try to remember everything, just comeback late and do the same lesson again, so you'll become use to it, You need time to adapt.</p>
</div>
<div class="step-by-step">
<div class="step">
<div class="step-number">1</div>
<div class="step-content">
<h4>Change the Page Title</h4>
<p>Look at the code in the editor. Find this line (it's near the top, inside the <head> section):</p>
<div class="code-inline"><title>Change This Title</title></div>
<p>Change the text between the tags to say "My First Web Page". After you change it, it should look like this:</p>
<div class="code-inline"><title>My First Web Page</title></div>
<p><em>Note: You won't see this change in the preview - it shows up in the browser tab!</em></p>
</div>
</div>
<div class="step">
<div class="step-number">2</div>
<div class="step-content">
<h4>Add Your Name as a Big Heading</h4>
<p>Now scroll down in the editor until you find this comment:</p>
<div class="code-inline"><!-- STEP 2: Add your h1 heading below this line --></div>
<p>Right below that comment (on a new line), type an h1 tag with your name inside:</p>
<div class="code-inline"><h1>John Smith</h1></div>
<p><em>Obviously, use YOUR actual name instead of John Smith! You should see your name appear in big letters in the preview.</em></p>
</div>
</div>
<div class="step">
<div class="step-number">3</div>
<div class="step-content">
<h4>Add a Paragraph Introducing Yourself</h4>
<p>Find the comment that says STEP 3. Below it, add a paragraph about yourself:</p>
<div class="code-inline"><p>Hello! I am learning web development and this is my first web page.</p></div>
<p><em>Feel free to write whatever you want! Just make sure it starts with <p> and ends with </p></em></p>
</div>
</div>
<div class="step">
<div class="step-number">4</div>
<div class="step-content">
<h4>Add a Section About Your Hobbies</h4>
<p>Find the STEP 4 comment. Add an h2 heading for a new section:</p>
<div class="code-inline"><h2>My Hobbies</h2></div>
<p><em>Notice this text will be smaller than your h1 name? That's because h2 is meant for section titles, not the main title.</em></p>
</div>
</div>
<div class="step">
<div class="step-number">5</div>
<div class="step-content">
<h4>Add a Paragraph About Your Hobbies</h4>
<p>Finally, find the STEP 5 comment and add one more paragraph:</p>
<div class="code-inline"><p>I enjoy reading, playing video games, and learning new things.</p></div>
<p><em>Write about YOUR actual hobbies! Make it personal.</em></p>
</div>
</div>
</div>
<div class="tip-box" style="margin-top: 2rem;">
<div class="note-header">
<div class="note-icon tip-icon"><i class="fas fa-check-circle"></i></div>
<div class="note-title tip-title">You're Almost Done!</div>
</div>
<p class="theory-text">Take a look at your preview - you should see your name as a big heading, a paragraph about yourself, a smaller "My Hobbies" heading, and another paragraph about your hobbies. If something looks wrong, check that all your tags are closed properly!</p>
<p class="theory-text">When you're happy with it, click the green <strong>"Submit Solution"</strong> button at the bottom of the editor. The system will check if you did everything correctly. You need to pass all checks to complete the lesson. If something's wrong, it will tell you what to fix.</p>
</div>
<div class="note-box" style="margin-top: 1.5rem;">
<div class="note-header">
<div class="note-icon"><i class="fas fa-trophy"></i></div>
<div class="note-title">Congratulations!</div>
</div>
<p class="theory-text">Once you complete this, you'll have created your first real web page. Now you can create text document and rename it <strong>index.html</strong> and open it with a text editor. After you've pasted the code into it, open it with a browser by right-clicking, and your page will open in the browser.</p>
<p><strong>See you next lesson!</strong></p>
</div>
`,
initialCode: {
html: `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Change This Title</title>
</head>
<body>
<!-- STEP 2: Add your h1 heading below this line -->
<!-- STEP 3: Add your introduction paragraph below -->
<!-- STEP 4: Add your h2 subheading below -->
<!-- STEP 5: Add your hobbies paragraph below -->
</body>
</html>`,
css: `/* CSS is pre-written for you - just focus on HTML! */
body {
font-family: 'Segoe UI', Arial, sans-serif;
max-width: 700px;
margin: 50px auto;
padding: 30px;
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
min-height: 100vh;
}
h1 {
color: white;
font-size: 2.5rem;
margin-bottom: 10px;
}
h2 {
color: rgba(255,255,255,0.9);
font-size: 1.5rem;
margin-top: 30px;
border-bottom: 2px solid rgba(255,255,255,0.3);
padding-bottom: 10px;
}
p {
color: rgba(255,255,255,0.85);
font-size: 1.1rem;
line-height: 1.8;
}`,
js: `// No JavaScript needed for this lesson`
},
hints: [
"π‘ Step 1: Find <title>Change This Title</title> and replace 'Change This Title' with 'My First Web Page'",
"π‘ Step 2: Type <h1>Your Name</h1> right below the <!-- STEP 2 --> comment",
"π‘ Step 3: Type <p>Your introduction text</p> below <!-- STEP 3 -->",
"π‘ Step 4: Type <h2>My Hobbies</h2> below <!-- STEP 4 -->",
"π‘ Step 5: Type <p>Your hobbies here</p> below <!-- STEP 5 -->",
"π‘ Make sure every tag is closed! <h1>text</h1> not <h1>text"
],
validation: (code) => {
const checks = [];
checks.push({
passed: code.html.includes('<title>My First Web Page</title>'),
message: 'β Title changed to "My First Web Page"'
});
checks.push({
passed: /<h1>[\s\S]+<\/h1>/i.test(code.html),
message: 'β Added h1 heading with your name'
});
checks.push({
passed: (code.html.match(/<p>[\s\S]*?<\/p>/gi) || []).length >= 2,
message: 'β Added two paragraphs'
});
checks.push({
passed: /<h2>[\s\S]*<\/h2>/i.test(code.html),
message: 'β Added h2 subheading'
});
return checks;
}
},
// ==========================================
// LESSON 2: HTML Elements & Tags
// ==========================================
'html-elements': {
title: 'Lists and Text Formatting',
subtitle: 'Learn to create bullet lists, numbered lists, and format text',
difficulty: 'Beginner',
duration: '20 minutes',
theory: `
<div class="theory-section">
<div class="section-header">
<div class="section-icon"><i class="fas fa-list"></i></div>
<h2 class="section-title">Why Do We Need Lists?</h2>
</div>
<p class="theory-text">Think about the last time you wrote a shopping list or a to-do list. You probably wrote items one below another, maybe with bullet points or numbers. It's organized, easy to read, and you can quickly see each item.</p>
<p class="theory-text">Without lists, you'd have to write everything in paragraphs like "I need to buy milk and eggs and bread and cheese and..." - that's hard to read! Lists make information clear and scannable. They're everywhere on the internet - recipe ingredients, navigation menus, feature lists, step-by-step instructions, you name it.</p>
<p class="theory-text">In this lesson, you'll learn how to create two types of lists and how to make text <strong>bold</strong> or <em>italic</em>. By the end, you'll build a complete recipe page!</p>
</div>
<div class="theory-section">
<div class="section-header">
<div class="section-icon"><i class="fas fa-circle"></i></div>
<h2 class="section-title">Bullet Lists (Unordered Lists)</h2>
</div>
<p class="theory-text">A bullet list is what you use when the order doesn't matter. Shopping list? Bullet points. List of your favorite movies? Bullet points. Features of a product? Bullet points.</p>
<p class="theory-text">In HTML, we call this an <strong>unordered list</strong>, and we use the tag <code><ul></code> (ul = unordered list). But here's the thing - the <code><ul></code> tag is just the container. Each actual item in the list needs its own tag: <code><li></code> (li = list item).</p>
<p class="theory-text">Think of it like a box and things inside the box. The <code><ul></code> is the box, and each <code><li></code> is something you put inside.</p>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-code"></i> Bullet List Example</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><code><ul>
<li>Apples</li>
<li>Bananas</li>
<li>Oranges</li>
</ul></code></pre>
</div>
<p class="theory-text">Let me break this down line by line:</p>
<p class="theory-text">β’ <code><ul></code> β "Hey browser, I'm starting a bullet list!"</p>
<p class="theory-text">β’ <code><li>Apples</li></code> β "Here's the first item: Apples"</p>
<p class="theory-text">β’ <code><li>Bananas</li></code> β "Here's another item: Bananas"</p>
<p class="theory-text">β’ <code><li>Oranges</li></code> β "And another: Oranges"</p>
<p class="theory-text">β’ <code></ul></code> β "Okay, that's the end of my list!"</p>
<div class="result-preview">
<strong>This creates:</strong>
<ul style="margin: 10px 0 0 20px; color: var(--text-secondary);">
<li>Apples</li>
<li>Bananas</li>
<li>Oranges</li>
</ul>
</div>
<div class="note-box">
<div class="note-header">
<div class="note-icon"><i class="fas fa-lightbulb"></i></div>
<div class="note-title">Common Mistake Alert!</div>
</div>
<p class="theory-text">Don't forget to close BOTH tags! You need <code></li></code> after each item AND <code></ul></code> at the very end. Missing any of these will break your list.</p>
</div>
</div>
<div class="theory-section">
<div class="section-header">
<div class="section-icon"><i class="fas fa-list-ol"></i></div>
<h2 class="section-title">Numbered Lists (Ordered Lists)</h2>
</div>
<p class="theory-text">Sometimes order DOES matter. If you're writing a recipe, you can't just randomly do steps - you need to preheat the oven BEFORE you put the food in, right? Or if you're explaining how to do something, step 1 has to come before step 2.</p>
<p class="theory-text">For these situations, we use an <strong>ordered list</strong> with the tag <code><ol></code> (ol = ordered list). The cool thing? The browser automatically adds the numbers for you! You don't have to type "1.", "2.", "3." - it just happens.</p>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-code"></i> Numbered List Example</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><code><ol>
<li>Preheat oven to 350Β°F</li>
<li>Mix all ingredients in a bowl</li>
<li>Pour into baking pan</li>
<li>Bake for 25 minutes</li>
</ol></code></pre>
</div>
<p class="theory-text">Notice something? The inside is exactly the same! You still use <code><li></code> for each item. The only difference is the outer tag: <code><ol></code> instead of <code><ul></code>.</p>
<div class="result-preview">
<strong>This creates:</strong>
<ol style="margin: 10px 0 0 20px; color: var(--text-secondary);">
<li>Preheat oven to 350Β°F</li>
<li>Mix all ingredients in a bowl</li>
<li>Pour into baking pan</li>
<li>Bake for 25 minutes</li>
</ol>
</div>
<div class="tip-box">
<div class="note-header">
<div class="note-icon tip-icon"><i class="fas fa-info-circle"></i></div>
<div class="note-title tip-title">Quick Summary</div>
</div>
<p class="theory-text"><code><ul></code> = bullets (unordered) β use when order doesn't matter</p>
<p class="theory-text"><code><ol></code> = numbers (ordered) β use when order matters</p>
<p class="theory-text"><code><li></code> = each item β used inside BOTH types of lists</p>
</div>
</div>
<div class="theory-section">
<div class="section-header">
<div class="section-icon"><i class="fas fa-bold"></i></div>
<h2 class="section-title">Making Text Bold and Italic</h2>
</div>
<p class="theory-text">Sometimes you want to emphasize certain words. Maybe you want to say "This cake is AMAZING" and really make that word pop. In HTML, we have special tags for this.</p>
<p class="theory-text">For <strong>bold text</strong>, we use the <code><strong></code> tag. It's called "strong" because you're making the text strongly emphasized - it's important!</p>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-code"></i> Bold Text</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><code><p>This cake is <strong>amazing</strong> and you should try it!</p></code></pre>
</div>
<p class="theory-text">This shows: This cake is <strong>amazing</strong> and you should try it!</p>
<p class="theory-text">For <em>italic text</em>, we use the <code><em></code> tag. "Em" stands for emphasis.</p>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-code"></i> Italic Text</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><code><p>You <em>really</em> need to try this recipe.</p></code></pre>
</div>
<p class="theory-text">Exemple: You <em>really</em> need to try this recipe.</p>
<div class="note-box">
<div class="note-header">
<div class="note-icon"><i class="fas fa-lightbulb"></i></div>
<div class="note-title">How It Works</div>
</div>
<p class="theory-text">Notice that <code><strong></code> and <code><em></code> go INSIDE your paragraph tags. You're not replacing the <code><p></code> tag - you're adding formatting to specific words within it. It's like highlighting certain words in a sentence you've already written.</p>
</div>
</div>
<p class="theory-text">Also you can try both <p> and <em>: <em><strong>Storng and Itallic</strong></em></p>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-code"></i> Italic Text</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><h6><code></code>This is how it should looks like: <em><strong> Your text inside! </strong></em></h6>
<h6>the order of <strong> and <em> should be only this way other wise it will not work!</h6></pre>
</div>
<div class="theory-section">
<div class="section-header">
<div class="section-icon"><i class="fas fa-layer-group"></i></div>
<h2 class="section-title">Putting It All Together</h2>
</div>
<p class="theory-text">Now you know headings (from lesson 1), paragraphs, lists, and text formatting. That's actually enough to build a lot of real web content! A typical recipe page uses ALL of these:</p>
<p class="theory-text">β’ <code><h1></code> for the recipe name</p>
<p class="theory-text">β’ <code><p></code> with <code><strong></code> for a tasty description</p>
<p class="theory-text">β’ <code><h2></code> for "Ingredients" section title</p>
<p class="theory-text">β’ <code><ul></code> with <code><li></code> items for the ingredient list</p>
<p class="theory-text">β’ <code><h2></code> for "Instructions" section title</p>
<p class="theory-text">β’ <code><ol></code> with <code><li></code> items for the cooking steps</p>
<p class="theory-text">See how it all connects?</p>
</div>
<div class="exercise-box">
<div class="exercise-header">
<div class="exercise-icon"><i class="fas fa-pencil-alt"></i></div>
<div class="exercise-title">π Your Task: Create a Recipe Page</div>
</div>
<p class="theory-text">Time to cook up some code! You're going to create a complete recipe page. It can be any recipe you like - cookies, pasta, a sandwich, whatever! Just follow the structure below.</p>
</div>
<div class="step-by-step">
<div class="step">
<div class="step-number">1</div>
<div class="step-content">
<h4>Add the Recipe Title</h4>
<p>Find <code><!-- STEP 1 --></code> in the editor and add a big heading with your recipe name:</p>
<div class="code-inline"><h1>Chocolate Chip Cookies</h1></div>
<p><em>Pick any recipe you want! Pizza, pancakes, smoothie - anything works.</em></p>
</div>
</div>
<div class="step">
<div class="step-number">2</div>
<div class="step-content">
<h4>Add a Tasty Description with Bold Text</h4>
<p>Find <code><!-- STEP 2 --></code> and add a paragraph that describes your recipe. Make at least one word bold using <code><strong></code>:</p>
<div class="code-inline"><p>These <strong>delicious</strong> cookies are perfect for any occasion!</p></div>
<p><em>The word "delicious" will appear in bold. You can make any word bold - "amazing", "easy", "homemade" - whatever fits!</em></p>
</div>
</div>
<div class="step">
<div class="step-number">3</div>
<div class="step-content">
<h4>Add "Ingredients" Section Heading</h4>
<p>Find <code><!-- STEP 3 --></code> and add a subheading for the ingredients section:</p>
<div class="code-inline"><h2>Ingredients</h2></div>
</div>
</div>
<div class="step">
<div class="step-number">4</div>
<div class="step-content">
<h4>Create a Bullet List of Ingredients</h4>
<p>Find <code><!-- STEP 4 --></code>. This is where it gets fun! Create an unordered list with at least 4 ingredients:</p>
<div class="code-inline"><ul>
<li>2 cups flour</li>
<li>1 cup sugar</li>
<li>1 cup butter</li>
<li>2 cups chocolate chips</li>
</ul></div>
<p><em>Remember: start with <ul>, then each ingredient gets its own <li>...</li>, then close with </ul>. Add as many ingredients as you want!</em></p>
</div>
</div>
<div class="step">
<div class="step-number">5</div>
<div class="step-content">
<h4>Add "Instructions" Section Heading</h4>
<p>Find <code><!-- STEP 5 --></code> and add another subheading:</p>
<div class="code-inline"><h2>Instructions</h2></div>
</div>
</div>
<div class="step">
<div class="step-number">6</div>
<div class="step-content">
<h4>Create a Numbered List of Steps</h4>
<p>Find <code><!-- STEP 6 --></code>. Now create an ordered list with at least 3 cooking steps:</p>
<div class="code-inline"><ol>
<li>Preheat oven to 375Β°F</li>
<li>Mix all ingredients together in a large bowl</li>
<li>Scoop onto baking sheet and bake for 10 minutes</li>
</ol></div>
<p><em>Same idea as before, but use <ol> instead of <ul>. The browser will automatically number your steps 1, 2, 3...</em></p>
</div>
</div>
</div>
<div class="tip-box" style="margin-top: 2rem;">
<div class="note-header">
<div class="note-icon tip-icon"><i class="fas fa-check-circle"></i></div>
<div class="note-title tip-title">Check Your Work</div>
</div>
<p class="theory-text">Before you hit Submit, look at the preview and make sure you see:</p>
<p class="theory-text">β A big recipe title at the top</p>
<p class="theory-text">β A description with at least one bold word</p>
<p class="theory-text">β "Ingredients" heading with bullet points below it</p>
<p class="theory-text">β "Instructions" heading with numbered steps below it</p>
<p class="theory-text">If something looks off, check your opening and closing tags!</p>
</div>
<div class="note-box" style="margin-top: 1.5rem;">
<div class="note-header">
<div class="note-icon"><i class="fas fa-trophy"></i></div>
<div class="note-title">Good Job!</div>
</div>
<p class="theory-text">Next lesson is in procces</p>
</div>
`,
initialCode: {
html: `<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>My Recipe</title>
</head>
<body>
<!-- STEP 1: Add recipe title (h1) below -->
<!-- STEP 2: Add description paragraph with bold text below -->
<!-- STEP 3: Add "Ingredients" heading (h2) below -->
<!-- STEP 4: Add bullet list (ul) with ingredients below -->
<!-- STEP 5: Add "Instructions" heading (h2) below -->
<!-- STEP 6: Add numbered list (ol) with steps below -->
</body>
</html>`,
css: `body {
font-family: Georgia, serif;
max-width: 650px;
margin: 0 auto;
padding: 40px 30px;
background: #fffaf0;
line-height: 1.8;
}
h1 {
color: #8b4513;
font-size: 2.2rem;
border-bottom: 3px solid #d2691e;
padding-bottom: 15px;
}
h2 {
color: #a0522d;
margin-top: 35px;
font-size: 1.4rem;
}
p { color: #5d4037; font-size: 1.1rem; }
ul, ol {
background: #fff8dc;
padding: 20px 40px;
border-radius: 10px;
border: 1px solid #deb887;
}
li {
padding: 8px 0;
color: #6d4c41;
}
strong { color: #d2691e; }`,
js: `// No JavaScript needed`
},
hints: [
"π‘ Step 1: Type <h1>Your Recipe Name</h1> - pick any food you like!",
"π‘ Step 2: Write a <p> paragraph and put <strong>one word</strong> in strong tags for bold",
"π‘ Step 3: Type <h2>Ingredients</h2>",
"π‘ Step 4: Start with <ul>, add <li>item</li> for each ingredient (at least 4!), end with </ul>",
"π‘ Step 5: Type <h2>Instructions</h2>",
"π‘ Step 6: Same as step 4, but use <ol> instead of <ul> for numbered steps"
],
validation: (code) => {
const checks = [];
checks.push({ passed: /<h1>[\s\S]+<\/h1>/i.test(code.html), message: 'β Added recipe title (h1)' });
checks.push({ passed: /<strong>[\s\S]+<\/strong>/i.test(code.html), message: 'β Used bold text (<strong>)' });
checks.push({ passed: (code.html.match(/<h2>/gi) || []).length >= 2, message: 'β Added two h2 headings' });
checks.push({ passed: /<ul>[\s\S]*<li>[\s\S]*<\/li>[\s\S]*<\/ul>/i.test(code.html), message: 'β Added bullet list (ul)' });
checks.push({ passed: /<ol>[\s\S]*<li>[\s\S]*<\/li>[\s\S]*<\/ol>/i.test(code.html), message: 'β Added numbered list (ol)' });
checks.push({ passed: (code.html.match(/<li>/gi) || []).length >= 7, message: 'β Added at least 7 list items total' });
return checks;
}
},
// ==========================================
// LESSON 3: Links & Images
// ==========================================
'html-links-images': {
title: 'Links and Images',
subtitle: 'Add clickable links and images to make your pages interactive',
difficulty: 'Beginner',
duration: '20 minutes',
theory: `
<div class="theory-section">
<div class="section-header">
<div class="section-icon"><i class="fas fa-link"></i></div>
<h2 class="section-title">What Are Links?</h2>
</div>
<p class="theory-text">Links (also called "hyperlinks") are clickable text or images that take you to another webpage, file, or even send an email. Think of them as doors that lead somewhere else.</p>
<p class="theory-text">In HTML, we make links using the <code><a></code> tag. The <code>a</code> stands for <strong>anchor</strong>.</p>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-code"></i> Exeple: Basic Link</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><code><a href="https://google.com">Click here to visit Google</a></code></pre>
</div>
<div class="note-box">
<div class="note-header">
<div class="note-icon"><i class="fas fa-puzzle-piece"></i></div>
<div class="note-title">Breaking it down</div>
</div>
<ul class="theory-list">
<li><code><a></code> β the link container</li>
<li><code>href="your link here"</code> β the destination address (like a URL)</li>
<li>The text between <code><a></code> and <code></a></code> β what the user sees and clicks</li>
</ul>
</div>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-code"></i> Open in a New Tab</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><code><a href="https://google.com" target="_blank">Google (new tab)</a></code></pre>
<p class="theory-text"><code>target="_blank"</code> tells the browser to open the link in a fresh tab.</p>
</div>
</div>
<div class="theory-section">
<div class="section-header">
<div class="section-icon"><i class="fas fa-image"></i></div>
<h2 class="section-title">Adding Images</h2>
</div>
<p class="theory-text">Images make your page look great! Use the <code><img></code> tag. Unlike most tags, it doesn't need a closing tag β it's self-closing.</p>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-code"></i> Image Example</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><code><img src="https://picsum.photos/300/200" alt="A random landscape"></code></pre>
</div>
<div class="note-box">
<div class="note-header">
<div class="note-icon"><i class="fas fa-tag"></i></div>
<div class="note-title">Image Attributes (settings)</div>
</div>
<ul class="theory-list">
<li><code>src</code> β the image source (where the image lives). Can be a web address or a local file.</li>
<li><code>alt</code> β alternative text describing the image. Important for accessibility (screen readers) and shows if the image fails to load. <strong>Always include it!</strong></li>
</ul>
</div>
<div class="tip-box">
<div class="note-header">
<div class="note-icon tip-icon"><i class="fas fa-camera"></i></div>
<div class="note-title tip-title">Free Practice Images</div>
</div>
<p class="theory-text">Use <code>https://picsum.photos/200/150</code> to get a random photo. The numbers are width and height. For a square, just use one number: <code>https://picsum.photos/150</code>.</p>
</div>
</div>
<div class="theory-section">
<div class="section-header">
<div class="section-icon"><i class="fas fa-envelope"></i></div>
<h2 class="section-title">Email Links</h2>
</div>
<p class="theory-text">Want a link that opens the user's email program? Use <code>mailto:</code> inside <code>href</code>.</p>
<div class="code-block">
<div class="code-block-header">
<div class="code-block-title"><i class="fas fa-code"></i> Email Link</div>
<button class="copy-code" onclick="copyCode(this)"><i class="fas fa-copy"></i> Copy</button>
</div>
<pre><code><a href="mailto:hello@example.com">Send me an email</a></code></pre>
<p class="theory-text">Clicking this will open the default email app with "hello@example.com" in the "To" field.</p>
</div>
</div>
<div class="exercise-box">
<div class="exercise-header">
<div class="exercise-icon"><i class="fas fa-pencil-alt"></i></div>
<div class="exercise-title"> Your Mission: Build a Profile Card</div>
</div>
<p class="theory-text">Now you'll create a small profile card that includes an image, your name, a short bio, a link to a website, and an email link. Follow the steps below. Don't worry if it's not perfect β just try!</p>
</div>
<div class="step-by-step">
<div class="step">
<div class="step-number">Step 1</div>
<div class="step-content">
<h4>Add a Profile Picture</h4>
<p>Find the comment <code><!-- STEP 1 --></code> in the code editor. Right after it, type:</p>
<div class="code-inline"><img src="https://picsum.photos/150" alt="My profile photo"></div>
</div>
</div>
<div class="step">
<div class="step-number">Step 2</div>
<div class="step-content">
<h4>Write Your Name</h4>
<p>Under <code><!-- STEP 2 --></code>, add your name inside <code><h1></code> tags:</p>
<div class="code-inline"><h1>Alex Johnson</h1></div>
<p>(Replace "Alex Johnson" with your own name, or any name you like.)</p>
</div>
</div>
<div class="step">
<div class="step-number">Step 3</div>
<div class="step-content">
<h4>Write a Short Bio</h4>
<p>Under <code><!-- STEP 3 --></code>, create a paragraph using <code><p></code>:</p>
<div class="code-inline"><p>I'm learning HTML and loving it!</p></div>
</div>
</div>
<div class="step">
<div class="step-number">Step 4</div>
<div class="step-content">
<h4>Add a Website Link</h4>
<p>Inside the <code><div class="links"></code> section, find <code><!-- STEP 4 --></code> and add a link:</p>
<div class="code-inline"><a href="https://github.com">My GitHub</a></div>
<p>You can change the URL and text to whatever you want.</p>
</div>
</div>
<div class="step">
<div class="step-number">Step 5</div>
<div class="step-content">