برای اینکه به المنت خود استایل بصورت inline اضافه کنید میبایست از خصوصیت style استفاده نمایید.
با استفاده از این خصوصیت خیلی سریع و راحت میتوانید به المنت خود رنگ،فونت، رنگ پس زمینه و … اضافه نمایید.
نحوه نوشتن:
1 |
<tagname style="property:value;"> |
درون خصوصیت به جای property از نام css و در value مقدار css را وارد نمایید.
مثال اضافه کردن استایل پس زمینه
1 2 3 4 5 6 7 8 9 |
<body style="background-color:powderblue;"> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> <body> <h1 style="background-color:powderblue;">This is a heading</h1> <p style="background-color:tomato;">This is a paragraph.</p> </body> |
تعریف رنگ متن برای المنت
1 2 |
<h1 style="color:blue;">This is a heading</h1> <p style="color:red;">This is a paragraph.</p> |
تعریف فونت برای المنت
1 2 |
<h1 style="font-family:verdana;">This is a heading</h1> <p style="font-family:courier;">This is a paragraph.</p> |
تعریف سایز فونت برای المنت
1 2 |
<h1 style="font-size:300%;">This is a heading</h1> <p style="font-size:160%;">This is a paragraph.</p> |
تراز متن توسط style برای المنت
1 2 |
<h1 style="text-align:center;">Centered Heading</h1> <p style="text-align:center;">Centered paragraph.</p> |