Methods to add css styles to jsp pages: 1. Use the "<link>" tag in the jsp page to link to the css style sheet; 2. Use the "<style>" tag in the document header in the jsp page Define the internal style sheet; 3. Use the style attribute in the tag element of the jsp page to include any css style.
#The operating environment of this tutorial: Windows 7 system, CSS3 version, Dell G3 computer.
Recommended: css video tutorial
There are three ways to insert CSS styles into JSP pages, and their priorities are different. The details are as follows: external style, internal style, and inline style. The priority increases in order!
【1】External styles
When styles need to be applied to many pages, external style sheets will be the ideal choice. With external style sheets, you can change the look of your entire site by changing one file. Each page links to the style sheet using the <link>
tag.
<link rel="stylesheet" type="text/css" href="<%=uiPath%>hwtt_ui/skins/<%=skinName%>/css/login.css" />
The rel attribute specifies the relationship between the current document and the linked document. In this example, the rel attribute indicates that the linked document is a style sheet.
【2】Internal styles
When a single document requires special styles, an internal style sheet should be used. Internal style sheets can be defined at the head of the document using the <style>
tag.
<style type="text/css"> .loginBtn{ display:block; cursor: pointer; height: 32px; margin-bottom: 1px; width: 100px; } </style>
[3] Inline styles
Inline styles lose many of the advantages of style sheets because they mix presentation and content. Use this approach with caution, for example when the style only needs to be applied once to an element. To use inline styles, you need to use the style attribute within the relevant tag. The Style property can contain any CSS property.
<input type="text" name="authCode" style="vertical-align: middle" />
For more programming-related knowledge, please visit: Programming Learning! !
The above is the detailed content of How to add css style to jsp page. For more information, please follow other related articles on the PHP Chinese website!