rgb() ফাংশন RGB রঙ মান সেট করতে ব্যবহৃত হয়। প্যারামিটার হিসেবে লাল, হরা, নীল রঙের तीব্রতা ০ থেকে ২৫৫ পর্যন্ত বা শতাংশে দেওয়া যায়।
উদাহরণ ১: টেক্সট এবং ব্যাকগ্রাউন্ড রঙ
<!DOCTYPE html> <html> <head> <style> div { text-align: justify; text-justify: inter-word; color: rgb(213,33,33); background-color: rgb(211,211,211); font-size: 1.1em; } </style> </head> <body> <h2>Demo Heading</h2> <div>This is demo text... </div> </body> </html>
আউটপুট

উদাহরণ ২: গ্রিড লেআউটে RGB রঙ
<!DOCTYPE html> <html> <head> <style> .demo { grid-area: newArea; font-size: xx-large; } .item3 { font-size: small; } .item4 { font-size: medium; } .item5 { font-size: x-large; } .grid-container { display: grid; grid-template-areas: 'newArea newArea . . .' 'newArea newArea . . .'; grid-gap: 5px; background-color: rgb(0,255,255); padding: 5px; } .grid-container > div { background-color: rgb(255, 50, 80); text-align: center; padding: 5px 0; } </style> </head> <body> <h1>Heading One</h1> <p>Set some random numbers</p> <div class="grid-container"> <div class="demo">250</div> <div class="item2">120</div> <div class="item3">333</div> <div class="item4">298</div> <div class="item5">645</div> <div class="item6">543</div> <div class="item7">555</div> </div> </body> </html>
আউটপুট

সিনট্যাক্স ভেরিয়েশন
rgb(255, 0, 0)— ০-২৫৫ INTEGER মানrgb(100%, 0%, 0%)— শতাংশ মানrgb(255 0 0)— আধুনিক স্পেস-সেপারেটেড সিনট্যাক্স (CSS Color Level 4)
নোট: আধুনিক ব্রাউজারগুলোতে rgba() আলাদা ফাংশন না হলেও rgb()-এই ৪র্থ প্যারামিটার (alpha) দিয়ে অপাসিটি দেওয়া যায়: rgb(255, 0, 0, 0.5)।