علامة HTML <body>


مثال

مستند HTML بسيط:

<html>
<head>
  <title>Title of the document</title>
</head>

<body>
  <h1>This is a heading</h1>
  <p>This is a paragraph.</p>
</body>

</html>

المزيد من الأمثلة "جربها بنفسك" أدناه.


التعريف والاستخدام

<body>تحدد العلامة نص المستند .

يحتوي <body>العنصر على جميع محتويات مستند HTML ، مثل العناوين والفقرات والصور والارتباطات التشعبية والجداول والقوائم وما إلى ذلك.

ملاحظة: يمكن أن يكون هناك <body> عنصر واحد فقط في مستند HTML.


دعم المتصفح

Element
<body> Yes Yes Yes Yes Yes

السمات العالمية

تدعم <body>العلامة أيضًا السمات العامة في HTML .


سمات الحدث

تدعم <body>العلامة أيضًا سمات الحدث في HTML .



مزيد من الأمثلة

مثال

أضف صورة خلفية إلى مستند (باستخدام CSS):

<html>
<head>
<style>
body {
  background-image: url(w3s.png);
}
</style>
</head>
<body>

<h1>Hello world!</h1>
<p><a href="https://www.w3schools.com">Visit W3Schools.com!</a></p>

</body>

مثال

اضبط لون الخلفية للمستند (باستخدام CSS):

<html>
<head>
<style>
body {
  background-color: #E6E6FA;
}
</style>
</head>
<body>

<h1>Hello world!</h1>
<p><a href="https://www.w3schools.com">Visit W3Schools.com!</a></p>

</body>

مثال

عيّن لون النص في مستند (باستخدام CSS):

<html>
<head>
<style>
body {
  color: green;
}
</style>
</head>
<body>

<h1>Hello world!</h1>
<p>This is some text.</p>
<p><a href="https://www.w3schools.com">Visit W3Schools.com!</a></p>

</body>
</html>

مثال

عيّن لون الروابط التي لم تتم زيارتها في مستند (باستخدام CSS):

<html>
<head>
<style>
a:link {
  color:#0000FF;
}
</style>
</head>
<body>

<p><a href="https://www.w3schools.com">W3Schools.com</a></p>
<p><a href="https://www.w3schools.com/html/">HTML Tutorial</a></p>

</body>
</html>

مثال

عيّن لون الروابط النشطة في مستند (باستخدام CSS):

<html>
<head>
<style>
a:active {
  color:#00FF00;
}
</style>
</head>
<body>

<p><a href="https://www.w3schools.com">W3Schools.com</a></p>
<p><a href="https://www.w3schools.com/html/">HTML Tutorial</a></p>

</body>
</html>

مثال

عيّن لون الروابط التي تمت زيارتها في مستند (باستخدام CSS):

<html>
<head>
<style>
a:visited {
  color:#FF0000;
}
</style>
</head>
<body>

<p><a href="https://www.w3schools.com">W3Schools.com</a></p>
<p><a href="https://www.w3schools.com/html/">HTML Tutorial</a></p>

</body>
</html>

الصفحات ذات الصلة

دروس HTML: عناصر HTML

مرجع DOM HTML: كائن الجسم

مرجع HTML DOM: خاصية document.body


إعدادات CSS الافتراضية

ستعرض معظم المتصفحات <body>العنصر بالقيم الافتراضية التالية:

مثال

body {
  display: block;
  margin: 8px;
}

body:focus {
  outline: none;
}