Lesson 4 / الدرس 4
Looking inside a page / النظر داخل الصفحة
Every browser has a set of developer tools built in. They let you see the page as the browser understands it, and change it live — the fastest way to learn, and the fastest way to fix.
في كل متصفح أدوات مطوّرين مدمجة. تتيح لك رؤية الصفحة كما يفهمها المتصفح، وتعديلها مباشرة — وهي أسرع طريقة للتعلّم، وأسرع طريقة للإصلاح.
You have written a file and opened it. When it looks wrong — and it will — you need a way to ask the browser what it actually did with your markup. That is what developer tools are for, and every browser has them already installed. This is the shortest lesson in the course and probably the most useful.
Opening them
-
Right-click anything on the page → Inspect. The surest way, and it jumps straight to the element you clicked. انقر بالزر الأيمن على أي شيء في الصفحة ← فحص (Inspect). أضمن طريقة، وتنقلك مباشرة إلى العنصر الذي نقرت عليه.
-
F12 on Windows and Linux. F12 على ويندوز ولينكس.
-
Cmd + Option + I on a Mac. Cmd + Option + I على الماك.
A panel opens beside or below the page. The tab you want first is Elements (Chrome and Edge) or Inspector (Firefox and Safari). It shows a tree of your page — and it is not your file. It is what the browser built after reading your file, which is the thing that actually matters when the two disagree.
<p>A paragraph
<p>Another one
<p> elements — the browser closed them for you. That gap between what you typed and what exists is invisible in your editor and obvious here.
<p> كاملين — فقد أغلقهما المتصفح عنك. وهذه الفجوة بين ما كتبته وما هو موجود غير مرئية في محررك، وواضحة تمامًا هنا.Changing the page without touching your file
Double-click any text in the Elements tree and type over it. Double-click a tag name and change it. The page updates immediately. Nothing you do here is saved — a refresh throws it all away — and that is exactly what makes it useful: you can try five things in a minute without risking the file you spent an hour on.
Two more panels are worth knowing now, even though you will use them properly later. Console reports problems — a file that failed to load shows up here in red and nowhere else. Network lists every file the page asked for and whether it arrived; a missing image is a red 404 line here.
404 هنا.| Panel | Answers |
|---|---|
| Elements / Inspector | What did the browser actually build from my markup? |
| Console | Did anything go wrong? |
| Network | Did every file I asked for arrive? |
| Device toolbar | How does this look on a phone? |
The four you will use for the rest of this course.
Try it live / جرّب بنفسك
Check yourself / اختبر نفسك
1. You edit some text in the Elements panel and refresh the page. What happens?
The panel shows what the browser built, not your file. Nothing you change there is written back, so a refresh rebuilds the page from your untouched source.
2. An image is not appearing. Which panel tells you fastest whether the file arrived?
Network lists every file the page requested and how the server answered. A missing image shows as a 404 line there.
404 هناك.3. Why can the Elements tree differ from the file you wrote?
The browser repairs and completes markup as it reads it. The tree is that finished result, which is why it is the honest answer to "what is on this page".
Score / النتيجة: 0 / 3
Your task / مهمتك
Open the page below in the editor, then open your browser's developer tools on this very page and find this task box in the Elements tree. Then, in the editor, deliberately leave one tag unclosed and run it — and look at what the browser built instead.
افتح الصفحة أدناه في المحرر، ثم افتح أدوات المطوّرين في متصفحك على هذه الصفحة نفسها وابحث عن صندوق المهمة هذا في شجرة Elements. ثم اترك في المحرر وسمًا واحدًا دون إغلاق عن قصد وشغّله — وانظر ماذا بنى المتصفح بدلًا منه.
- You opened the developer tools at least once فتحت أدوات المطوّرين مرة واحدة على الأقل
- The page has a heading and two paragraphs الصفحة فيها عنوان وفقرتان
- One tag is deliberately left unclosed, so you can see what the browser does وسم واحد متروك دون إغلاق عن قصد، لترى ما يفعله المتصفح