Summary of three ways to insert an css style into an jsp page

  • 2020-11-03 22:33:32
  • OfStack

1. External style

When styles need to be applied to many pages, external stylesheets are ideal. In the case of external stylesheets, you can change the look of the entire site by changing 1 file. Use per page < link > The tag links to the style sheet. < link > The label is at the head of (a document) :

< head >
< link rel="stylesheet" type="text/css" href="path/myCss.css"/ >
< /head >

2. Internal style

An internal style sheet should be used when a particular style is required for a single document. You can use < style > The tag defines the internal style sheet in the document header.

< head >
< style type="text/css" >
style
< /style >
< /head >

3. Inline style

By mixing presentation and content at the same time, inline styles lose many of the advantages of style sheets. Use this approach with caution, such as when the style needs to be applied only once on an element. To use inline styles, you need to use the style (style) attribute within the associated tag. The Style attribute can contain any CSS attribute.

Inline styles have the highest priority, followed by internal styles, and external styles have the lowest priority.


Related articles: