–
۸. استایل در HTML
<!DOCTYPE html>
<html>
<body>
<p>I am normal</p>
<p style="color:red;">I am red</p>
<p style="color:blue;">I am blue</p>
<p style="font-size:50px;">I am big</p>
</body>
</html>

I am normal
I am red
I am blue
I am big
<tagname style="property:value;">
بعداً در مورد CSS بیشتر خواهید آموخت.
رنگ پس زمینه
<!DOCTYPE html>
<html>
<body style="background-color:powderblue;">
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>

This is a heading
This is a paragraph.
مثال۲:
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:powderblue;">This is a heading</h1>
<p style="background-color:tomato;">This is a paragraph.</p>
</body>
</html>

This is a heading
This is a paragraph.
رنگ متن
<!DOCTYPE html>
<html>
<body>
<h1 style="color:blue;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
</body>
</html>

This is a heading
This is a paragraph.
فونت ها
<!DOCTYPE html>
<html>
<body>
<h1 style="font-family:verdana;">This is a heading</h1>
<p style="font-family:courier;">This is a paragraph.</p>
</body>
</html>

This is a heading
This is a paragraph.
اندازه متن
<!DOCTYPE html>
<html>
<body>
<h1 style="font-size:300%;">This is a heading</h1>
<p style="font-size:160%;">This is a paragraph.</p>
</body>
</html>

This is a heading
This is a paragraph.
ترازبندی متن
<!DOCTYPE html>
<html>
<body>
<h1 style="text-align:center;">Centered Heading</h1>
<p style="text-align:center;">Centered paragraph.</p>
</body>
</html>

Centered Heading
Centered paragraph.
خلاصه این قسمت:
-
از ویژگی style برای استایل دادن به عناصر HTML استفاده می شود.
-
از background-color برای رنگ پس زمینه استفاده می شود.
-
از color برای رنگ های متن استفاده می شود.
-
از font-family برای فونت های متنی استفاده می شود.
-
از font-size برای اندازه متن استفاده می شود.
-
از text-align برای تراز کردن متن استفاده می شود.
–
۹. قالب بندی متن
<!DOCTYPE html>
<html>
<body>
<p><b>This text is bold</b></p>
<p><i>This text is italic</i></p>
<p>This is<sub> subscript</sub> and <sup>superscript</sup></p>
</body>
</html>

This text is bold
This text is italic
This is subscript and superscript
قالب بندی عناصر
-
<b> – متن بولد
-
<strong> – متن مهم
-
<i> – متن ایتالیک
-
<em> – متن تاکید شده
-
<mark> – متن علامت گذاری شده
-
<small> – متن کوچکتر
-
<del> – متن حذف شده
-
<ins> – متن درج شده
-
<sub> – متن زیرنویس
-
<sup> – متن بالانویس
عناصر <b> و <strong>
<!DOCTYPE html>
<html>
<body>
<p>This text is normal.</p>
<p><b>This text is bold.</b></p>
<strong>This text is important!</strong>
</body>
</html>

This text is normal.
This text is bold.
This text is important!
عناصر <i> و <em>
<!DOCTYPE html>
<html>
<body>
<p>This text is normal.</p>
<p><i>This text is italic.</i></p>
<em>This text is emphasized</em>
</body>
</html>

This text is normal.
This text is italic.
This text is emphasizedعنصر <small>
<!DOCTYPE html>
<html>
<body>
<p>This is some normal text.</p>
<p><small>This is some smaller text.</small></p>
</body>
</html>

This is some normal text.
This is some smaller text.
عنصر <mark>
<!DOCTYPE html>
<html>
<body>
<p>Do not forget to buy <mark>milk</mark> today.</p>
</body>
</html>

Do not forget to buy milk today.
عنصر <del>
<!DOCTYPE html>
<html>
<body>
<p>My favorite color is <del>blue</del> red.</p>
</body>
</html>

My favorite color is blue red.
عنصر <ins>
<!DOCTYPE html>
<html>
<body>
<p>My favorite color is <del>blue</del> <ins>red</ins>.</p>
</body>
</html>

My favorite color is blue red.
عنصر <sub>
<!DOCTYPE html>
<html>
<body>
<p>This is <sub>subscripted</sub> text.</p>
</body>
</html>

This is subscripted text.
عنصر <sup>
<!DOCTYPE html>
<html>
<body>
<p>This is <sup>superscripted</sup> text.</p>
</body>
</html>

This is superscripted text.
خلاصه عناصر قالب بندی متن:
- <b> متن پر رنگ را تعریف می کند
- <em> متن تاکید شده را تعریف می کند
- <i> بخشی از متن را italic می کند
- <small> متن کوچکتر را تعریف می کند
- <strong> متن مهم را تعریف می کند
- <sub> متن زیرنویس را تعریف می کند
- <sup> متن بالانویس را تعریف می کند
- <ins> متن درج شده را تعریف می کند
- <del> متن حذف شده را تعریف می کند
- <mark> متن هایلایت شده را تعریف می کند
–
۱۰. عناصر نقل قول
- عنصر <blockquote> بخشی را تعریف می کند که از منبع دیگری نقل شده است. مرورگرها معمولاً عناصر <blockquote> را با تورفتگی نشان می دهند.
- تگ <q> یک نقل قول کوتاه را تعریف می کند.
-
تگ <abbr> یک مخفف یا مخفف مانند “HTML”، “CSS”، “Mr.”، “Dr.”، “ASAP”، “ATM” را تعریف می کند.
<!DOCTYPE html>
<html>
<body>
<p>The <abbr title="World Health Organization">WHO</abbr> was founded in 1948.</p>
<p>Marking up abbreviations can give useful information to browsers, translation systems and search-engines.</p>
</body>
</html>

The WHO was founded in 1948.
Marking up abbreviations can give useful information to browsers, translation systems and search-engines.
-
تگ <address> اطلاعات تماس نویسنده/مالک یک سند یا مقاله را تعریف می کند.اطلاعات تماس می تواند آدرس ایمیل، آدرس اینترنتی، آدرس فیزیکی، شماره تلفن، دسته رسانه های اجتماعی و غیره باشد.متن موجود در عنصر <address> معمولاً به صورت مورب ارائه می شود و مرورگرها همیشه قبل و بعد از عنصر <address> یک line break اضافه می کنند.
- تگ <cite> عنوان یک اثر خلاقانه (مانند یک کتاب، یک شعر، یک آهنگ، یک فیلم، یک نقاشی، یک مجسمه و غیره) را تعریف می کند.
متن موجود در عنصر <cite> معمولا به صورت ایتالیک ارائه می شود.
- تگ <bdo> برای نادیده گرفتن جهت متن فعلی استفاده می شود:
<!DOCTYPE html>
<html>
<body>
<p>If your browser supports bi-directional override (bdo), the next line will be written from right to left (rtl):</p>
<bdo dir="rtl">This line will be written from right to left</bdo>
</body>
</html>

If your browser supports bi-directional override (bdo), the next line will be written from right to left (rtl):
This line will be written from right to left
–
۱۱. تگ Comment (اظهار نظر)
<!-- Write your comments here -->
توجه: comment ها توسط مرورگر نمایش داده نمی شوند، اما می توانند به مستندسازی کد منبع HTML شما کمک کنند.
<!DOCTYPE html>
<html>
<body>
<!-- This is a comment -->
<p>This is a paragraph.</p>
<!-- Comments are not displayed in the browser -->
</body>
</html>

This is a paragraph.
-->
و <!--
از نمایشگر پنهان می شود.
<!DOCTYPE html>
<html>
<body>
<p>This is a paragraph.</p>
<!--
<p>Look at this cool image:</p>
<img border="0" src="pic_trulli.jpg" alt="Trulli">
-->
<p>This is a paragraph too.</p>
</body>
</html>

This is a paragraph.
This is a paragraph too.
مخفی کردن محتوای درون خطی
<!DOCTYPE html>
<html>
<body>
<p>This <!-- great text --> is a paragraph.</p>
</body>
</html>

This is a paragraph.
–
۱۲. رنگها
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:Tomato;">Tomato</h1>
<h1 style="background-color:Orange;">Orange</h1>
<h1 style="background-color:DodgerBlue;">DodgerBlue</h1>
<h1 style="background-color:MediumSeaGreen;">MediumSeaGreen</h1>
<h1 style="background-color:Gray;">Gray</h1>
<h1 style="background-color:SlateBlue;">SlateBlue</h1>
<h1 style="background-color:Violet;">Violet</h1>
<h1 style="background-color:LightGray;">LightGray</h1>
</body>
</html>

Tomato
Orange
DodgerBlue
MediumSeaGreen
Gray
SlateBlue
Violet
LightGray
رنگ پس زمینه
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:DodgerBlue;">Hello World</h1>
<p style="background-color:Tomato;">
Lorem ipsum dolor sit amet, consectetuer adipiscing
elit, sed diam nonummy nibh euismod tincidunt ut
laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci
tation ullamcorper suscipit lobortis nisl ut aliquip
ex ea commodo consequat.
</p>
</body>
</html>

Hello World
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
رنگ متن
<!DOCTYPE html>
<html>
<body>
<h3 style="color:Tomato;">Hello World</h3>
<p style="color:DodgerBlue;">Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.</p>
<p style="color:MediumSeaGreen;">Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.</p>
</body>
</html>

Hello World
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.
Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
رنگ حاشیه
<!DOCTYPE html>
<html>
<body>
<h1 style="border: 2px solid Tomato;">Hello World</h1>
<h1 style="border: 2px solid DodgerBlue;">Hello World</h1>
<h1 style="border: 2px solid Violet;">Hello World</h1>
</body>
</html>

Hello World
Hello World
Hello World
مقادیر رنگ
<!DOCTYPE html>
<html>
<body>
<p>Same as color name "Tomato":</p>
<h1 style="background-color:rgb(255, 99, 71);">rgb(255, 99, 71)</h1>
<h1 style="background-color:#ff6347;">#ff6347</h1>
<h1 style="background-color:hsl(9, 100%, 64%);">hsl(9, 100%, 64%)</h1>
<p>Same as color name "Tomato", but 50% transparent:</p>
<h1 style="background-color:rgba(255, 99, 71, 0.5);">rgba(255, 99, 71, 0.5)</h1>
<h1 style="background-color:hsla(9, 100%, 64%, 0.5);">hsla(9, 100%, 64%, 0.5)</h1>
<p>In addition to the predefined color names, colors can be specified using
RGB, HEX, HSL, or even transparent colors using RGBA or HSLA color values.
</p>
</body>
</html>

Same as color name “Tomato”:
rgb(255, 99, 71)
#ff6347
hsl(9, 100%, 64%)
Same as color name “Tomato”, but 50% transparent:
rgba(255, 99, 71, 0.5)
hsla(9, 100%, 64%, 0.5)
In addition to the predefined color names, colors can be specified using RGB, HEX, HSL, or even transparent colors using RGBA or HSLA color values.
در قسمت های بعدی بیشتر با RGB، HEX و HSL آشنا خواهید شد.
رنگ های RGB و RGBA
مقادیر رنگ RGB
rgb(red, green, blue)
مثال:
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:rgb(255, 0, 0);">rgb(255, 0, 0)</h1>
<h1 style="background-color:rgb(0, 0, 255);">rgb(0, 0, 255)</h1>
<h1 style="background-color:rgb(60, 179, 113);">rgb(60, 179, 113)</h1>
<h1 style="background-color:rgb(238, 130, 238);">rgb(238, 130, 238)</h1>
<h1 style="background-color:rgb(255, 165, 0);">rgb(255, 165, 0)</h1>
<h1 style="background-color:rgb(106, 90, 205);">rgb(106, 90, 205)</h1>
</body>
</html>

rgb(255, 0, 0)
rgb(0, 0, 255)
rgb(60, 179, 113)
rgb(238, 130, 238)
rgb(255, 165, 0)
rgb(106, 90, 205)
سایه های خاکستری
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:rgb(60, 60, 60);">rgb(60, 60, 60)</h1>
<h1 style="background-color:rgb(100, 100, 100);">rgb(100, 100, 100)</h1>
<h1 style="background-color:rgb(140, 140, 140);">rgb(140, 140, 140)</h1>
<h1 style="background-color:rgb(180, 180, 180);">rgb(180, 180, 180)</h1>
<h1 style="background-color:rgb(200, 200, 200);">rgb(200, 200, 200)</h1>
<h1 style="background-color:rgb(240, 240, 240);">rgb(240, 240, 240)</h1>
</body>
</html>

rgb(60, 60, 60)
rgb(100, 100, 100)
rgb(140, 140, 140)
rgb(180, 180, 180)
rgb(200, 200, 200)
rgb(240, 240, 240)
مقادیر رنگ RGBA
rgba(red, green, blue, alpha)
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:rgba(255, 99, 71, 0);">rgba(255, 99, 71, 0)</h1>
<h1 style="background-color:rgba(255, 99, 71, 0.2);">rgba(255, 99, 71, 0.2)</h1>
<h1 style="background-color:rgba(255, 99, 71, 0.4);">rgba(255, 99, 71, 0.4)</h1>
<h1 style="background-color:rgba(255, 99, 71, 0.6);">rgba(255, 99, 71, 0.6)</h1>
<h1 style="background-color:rgba(255, 99, 71, 0.8);">rgba(255, 99, 71, 0.8)</h1>
<h1 style="background-color:rgba(255, 99, 71, 1);">rgba(255, 99, 71, 1)</h1>
</body>
</html>

rgba(255, 99, 71, 0)
rgba(255, 99, 71, 0.2)
rgba(255, 99, 71, 0.4)
rgba(255, 99, 71, 0.6)
rgba(255, 99, 71, 0.8)
rgba(255, 99, 71, 1)
مقادیر رنگ HEX
#RRGGBB
مشخص می شود، که در آن اعداد صحیح هگزا دسیمال RR (قرمز)، GG (سبز) و BB (آبی) اجزای رنگ را مشخص می کنند.
#rrggbb
#ff0000
به صورت قرمز نمایش داده می شود، زیرا قرمز روی بالاترین مقدار خود (ff) و دو مورد دیگر (سبز و آبی) روی 00 تنظیم شده است.#00ff00
به صورت سبز نمایش داده می شود، زیرا رنگ سبز روی بالاترین مقدار خود (ff) و دو مورد دیگر (قرمز و آبی) روی 00 تنظیم شده است.#000000
.#ffffff
.
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:#ff0000;">#ff0000</h1>
<h1 style="background-color:#0000ff;">#0000ff</h1>
<h1 style="background-color:#3cb371;">#3cb371</h1>
<h1 style="background-color:#ee82ee;">#ee82ee</h1>
<h1 style="background-color:#ffa500;">#ffa500</h1>
<h1 style="background-color:#6a5acd;">#6a5acd</h1>
</body>
</html>

#ff0000
#0000ff
#3cb371
#ee82ee
#ffa500
#6a5acd
سایه های خاکستری
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:#404040;">#404040</h1>
<h1 style="background-color:#686868;">#686868</h1>
<h1 style="background-color:#a0a0a0;">#a0a0a0</h1>
<h1 style="background-color:#bebebe;">#bebebe</h1>
<h1 style="background-color:#dcdcdc;">#dcdcdc</h1>
<h1 style="background-color:#f8f8f8;">#f8f8f8</h1>
</body>
</html>

#404040
#686868
#a0a0a0
#bebebe
#dcdcdc
#f8f8f8
مقادیر رنگ HSL
hsl(hue, saturation, lightness)
مثال:
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:hsl(0, 100%, 50%);">hsl(0, 100%, 50%)</h1>
<h1 style="background-color:hsl(240, 100%, 50%);">hsl(240, 100%, 50%)</h1>
<h1 style="background-color:hsl(147, 50%, 47%);">hsl(147, 50%, 47%)</h1>
<h1 style="background-color:hsl(300, 76%, 72%);">hsl(300, 76%, 72%)</h1>
<h1 style="background-color:hsl(39, 100%, 50%);">hsl(39, 100%, 50%)</h1>
<h1 style="background-color:hsl(248, 53%, 58%);">hsl(248, 53%, 58%)</h1>
</body>
</html>

hsl(0, 100%, 50%)
hsl(240, 100%, 50%)
hsl(147, 50%, 47%)
hsl(300, 76%, 72%)
hsl(39, 100%, 50%)
hsl(248, 53%, 58%)
Saturation (اشباع)
- 100٪ رنگ خالص است، بدون سایه های خاکستری.
- 50% به مقدار 50% خاکستری دارد، اما همچنان می توانید رنگ را ببینید.
- 0% کاملا خاکستری است. شما دیگر نمی توانید رنگ را ببینید.
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:hsl(0, 100%, 50%);">hsl(0, 100%, 50%)</h1>
<h1 style="background-color:hsl(0, 80%, 50%);">hsl(0, 80%, 50%)</h1>
<h1 style="background-color:hsl(0, 60%, 50%);">hsl(0, 60%, 50%)</h1>
<h1 style="background-color:hsl(0, 40%, 50%);">hsl(0, 40%, 50%)</h1>
<h1 style="background-color:hsl(0, 20%, 50%);">hsl(0, 20%, 50%)</h1>
<h1 style="background-color:hsl(0, 0%, 50%);">hsl(0, 0%, 50%)</h1>
<p>With HSL colors, less saturation mean less color. 0% is completely gray.</p>
</body>
</html>

hsl(0, 100%, 50%)
hsl(0, 80%, 50%)
hsl(0, 60%, 50%)
hsl(0, 40%, 50%)
hsl(0, 20%, 50%)
hsl(0, 0%, 50%)
With HSL colors, less saturation mean less color. 0% is completely gray.
روشنایی
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:hsl(0, 100%, 0%);">hsl(0, 100%, 0%)</h1>
<h1 style="background-color:hsl(0, 100%, 25%);">hsl(0, 100%, 25%)</h1>
<h1 style="background-color:hsl(0, 100%, 50%);">hsl(0, 100%, 50%)</h1>
<h1 style="background-color:hsl(0, 100%, 75%);">hsl(0, 100%, 75%)</h1>
<h1 style="background-color:hsl(0, 100%, 90%);">hsl(0, 100%, 90%)</h1>
<h1 style="background-color:hsl(0, 100%, 100%);">hsl(0, 100%, 100%)</h1>
<p>With HSL colors, 0% lightness means black, and 100 lightness means white.</p>
</body>
</html>

hsl(0, 100%, 0%)
hsl(0, 100%, 25%)
hsl(0, 100%, 50%)
hsl(0, 100%, 75%)
hsl(0, 100%, 90%)
hsl(0, 100%, 100%)
With HSL colors, 0% lightness means black, and 100 lightness means white.
سایه های خاکستری
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:hsl(0, 0%, 20%);">hsl(0, 0%, 20%)</h1>
<h1 style="background-color:hsl(0, 0%, 30%);">hsl(0, 0%, 30%)</h1>
<h1 style="background-color:hsl(0, 0%, 40%);">hsl(0, 0%, 40%)</h1>
<h1 style="background-color:hsl(0, 0%, 60%);">hsl(0, 0%, 60%)</h1>
<h1 style="background-color:hsl(0, 0%, 70%);">hsl(0, 0%, 70%)</h1>
<h1 style="background-color:hsl(0, 0%, 90%);">hsl(0, 0%, 90%)</h1>
</body>
</html>

hsl(0, 0%, 20%)
hsl(0, 0%, 30%)
hsl(0, 0%, 40%)
hsl(0, 0%, 60%)
hsl(0, 0%, 70%)
hsl(0, 0%, 90%)
مقادیر رنگ HSLA
hsla(hue, saturation, lightness, alpha)
مثال:
<!DOCTYPE html>
<html>
<body>
<h1 style="background-color:hsla(9, 100%, 64%, 0);">hsla(9, 100%, 64%, 0)</h1>
<h1 style="background-color:hsla(9, 100%, 64%, 0.2);">hsla(9, 100%, 64%, 0.2)</h1>
<h1 style="background-color:hsla(9, 100%, 64%, 0.4);">hsla(9, 100%, 64%, 0.4)</h1>
<h1 style="background-color:hsla(9, 100%, 64%, 0.6);">hsla(9, 100%, 64%, 0.6)</h1>
<h1 style="background-color:hsla(9, 100%, 64%, 0.8);">hsla(9, 100%, 64%, 0.8)</h1>
<h1 style="background-color:hsla(9, 100%, 64%, 1);">hsla(9, 100%, 64%, 1)</h1>
</body>
</html>
