English

Which CSS code would be applied to an element, the one defined within the STYLE element of the page or the one defined within the style property of the element?

Advertisements
Advertisements

Question

Which CSS code would be applied to an element, the one defined within the STYLE element of the page or the one defined within the style property of the element? Take the following code as an example. What would be the size of the font in the DIV element?

<html>
  <head>
    <title>My page</title>
    <style type="text/css">
    div {   font-family: Verdana;
       font-size: 9pt;
        }
    </style>
  </head>
  <body>
    <div style="font-weight: bold; font-size: 12pt;"> My text </div>
  </body>
</html>
Code Writing
Short Answer
Advertisements

Solution

Both would be applied, but the one specified in the style property would be fully applied and might take priority over the code specified in the page’s STYLE element. The following style would be applied to the DIV element (the value in the style property would take priority over the font-size):

font-family: Verdana; font-weight: bold; font-size: 12pt;
shaalaa.com
  Is there an error in this question or solution?
Chapter 6: Cascading Style Sheets (CSS) - Assisted Practice [Page 273]

APPEARS IN

Sumita Arora Computer Applications [English] Class 10
Chapter 6 Cascading Style Sheets (CSS)
Assisted Practice | Q 2. | Page 273
Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×