Chapter: Internet & World Wide Web HOW TO PROGRAM - The Ajax Client - Cascading Style Sheets (CSS)

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail

Inline Styles - CSS

You can declare document styles in several ways. This section presents inline styles that declare an individual element’s format using the XHTML attribute style.

Inline Styles

 

You can declare document styles in several ways. This section presents inline styles that declare an individual element’s format using the XHTML attribute style. Inline styles override any other styles applied using the techniques we discuss later in the chapter. Figure 5.1 applies inline styles to p elements to alter their font size and color.

The first inline style declaration appears in line 17. Attribute style specifies an ele-ment’s style. Each CSS property (font-size in this case) is followed by a colon and a value. In line 17, we declare this particular p element to use 20-point font size.

      <?xml version = "1.0" encoding = "utf-8"?>

 

      <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

 

      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

 

      <!-- Fig. 5.1: inline.html -->

 

      <!-- Using inline styles -->

 

      <html xmlns = "http://www.w3.org/1999/xhtml">

 

      <head>

 

      <title>Inline Styles</title>

 

        </head>

 

        <body>

 

        <p>This text does not have any style applied to it.</p>

 

        <!-- The style attribute allows you to declare -->

 

        <!-- inline styles. Separate multiple style properties -->

 

        <!-- with a semicolon. -->

 

        <p style = "font-size: 20pt">This text has the

 

        <em>font-size</em> style applied to it, making it 20pt.

        </p>

        <p style = "font-size: 20pt; color: #6666ff">

 

        This text has the <em>font-size</em> and

 

        <em>color</em> styles applied to it, making it

 

        20pt. and light blue.</p>

 

        </body>

 

</html>


Fig. 5.1 | Using inline styles.

 

Line 21 specifies the two properties, font-size and color, separated by a semicolon. In this line, we set the given paragraph’s color to light blue, using the hexadecimal code #6666ff. Color names may be used in place of hexadecimal codes. We provide a list of hexadecimal color codes and color names in Appendix B, XHTML Colors.

 

Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail


Copyright © 2018-2020 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.