



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The three ways to associate styles with an HTML document: in-line, embedded, and external style sheets. It provides syntax and examples for each method, including the use of the <link> tag to include an external style sheet file. The document also explains the attributes of the <link> tag and provides sample programs for in-line and external style sheets. useful for web developers who want to learn how to apply styles to their HTML documents.
Typology: Study notes
1 / 7
This page cannot be seen from the preview
Don't miss anything!




A style is simply a set of formatting instructions that can be applied to a piece of text. There are three ways that styles can be associated with an HTML document. First, styles can be placed in-line in a document. Second, a style sheet can be embedded in the head of an HTML document. The third way of associating web pages with style sheets is to place a link in the head of the HTML file to an external style sheet. With this link, when the browser begins reading the page, it sees the style sheet link, and downloads the style sheet, then uses the style sheet to draw the page There are three mechanisms by which we can apply styles to our HTML documents. There are: a) Inline style sheet: Provide an inline style using the style needs to be applied. The style can be defined within the basic HTML tags. b) Embedding and importing style sheets: It is also called as Internal style sheet. Embed a document – wide style in the head element of the document. Style can be defined in the section and applied to the whole document. c) External style sheet: Styles can be defined in external files which can then be used in any document by including the style sheet via a URL.
An inline CSS is used to apply a unique style to a single HTML element. It uses the style attribute of an HTML element. Style information can be add to directly in a single element. Suppose we want to set different properties to a tag we can use style attribute. It is very easy to use style attribute. If we want to affect more tags with the same properties, simply we would have to copy-paste the style attribute into every other tag. Style: The value of style attribute is a combination of style declarations separated by semicolon (;). Syntax : < html > < head > < title > …………….< /title > < /head > < body > < tag style = “property 1 : value; property 2: value ; …… property n : value “ > some text here
< /tag > < tag style = “property 1 : value; property 2 : value ; …… property n : value”> some text here < /tag > < /body > < /html > **For example: This is inline CSS **
**Program: Write a program for In-Line style sheet
Inline style sheet
Inline styles are applied to H1 tag.
we are using styles in bold tag.
Output:**
property 2 : value ;
.. .. .. property n : value ; } tag 2 { property 1 : value; property 2 : value ; .. .. .. property n : value ; }
**
**
This is a heading
This is a paragraph.
Output:**
An external style sheet is simply a plain text file containing the style specifications
used to include an external style sheet file in your HTML document LINK tag: Link element specifies a relation ship between the current document and another document using the “rel” attribute. In this case, we declare the linked document to be a “stylesheet” for this document. We use the “Type” attribute to specify the MIME type as “text/css” and provide the URL for the style sheet with the “href” attribute. ** Attributes: rel :** It specifies the relation ship between the current document and another document. type : It specifies the style sheet language as a content-type (MIME type).