The HTML Style Attribute
For adding styles in an element such as size, color, font, and more, you can define the HTML style attribute.
Syntax
Here is the following syntax of HTML style attribute:
<elemnt-name style="property:value;">
Background Color
<!DOCTYPE html> <html> <body style="background-color:red;"> <p>This is my first paragraph.</p> <p>This is my second paragraph.</p> </body> </html>
Output
This is my first paragraph.
This is my second paragraph.
Text Size
<!DOCTYPE html> <html> <body"> <p style="font-size:30px;">This is my first paragraph.</p> <p>This is my second paragraph.</p> </body> </html>
Output
This is my first paragraph.
This is my second paragraph.
Text Color
<!DOCTYPE html> <html> <body"> <p style="color:green;">This is my first paragraph.</p> <p>This is my second paragraph.</p> </body> </html>
Output
This is my first paragraph.
This is my second paragraph.