HTML5: How to define style information for a document?
Solution:
HTML Code:
Explanation:
- This HTML code defines a webpage with a heading and a paragraph.
- Inside the <head> section, an internal CSS style block is used to define styles for specific HTML elements.
- The h1 {color:green;} CSS rule sets the color of <h1> elements to green.
- The p {color:blue;} CSS rule sets the color of <p> elements to blue.
- As a result, the heading "w3resource" will be displayed in green, and the paragraph text will be displayed in blue, according to the defined styles.
Live Demo:
See the solution in the browser
Supported browser
![]() |
![]() |
![]() |
![]() |
![]() |
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.