Home >Web Front-end >Front-end Q&A >How to introduce css into jsp
How to introduce css into jsp: 1. Use the href attribute in the link tag to introduce the css file path; 2. Use the internal style sheet to introduce css; 3. Inline style to introduce css.
The operating environment of this article: Windows 7 system, CSS3 version, Dell G3 computer.
There are three ways to introduce 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!
jsp can use the href attribute in the link tag to introduce the css file path.
First save the written css style sheet content in *.css format. For example, style.css
introduces this css style file into the page. Introduce it in the following way.
<link rel="stylesheet" href="./css/style.css" type="text/css">
The href="./css/style.css" here refers to the path where the css file is stored. '.'Requests the current directory (that is, the same directory as the jsp page that introduces the css file)
The rel attribute specifies the relationship between the current document and the linked document. In this example, the rel attribute indicates the linked document. is a style sheet.
Two other ways to use css in jsp:
Internal style
When When a single document requires special styling, an internal style sheet should be used. Internal style sheets can be defined at the head of the document using the c9ccee2e6ea535a969eb3f532ad9fe89 tag.
Add styles using class selectors.
<style type="text/css"> .loginBtn{ display:block; cursor: pointer; height: 32px; margin-bottom: 1px; width: 100px; } </style>
Inline styles
Inline styles lose many of the advantages of style sheets by mixing presentation with 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 detailed HTML/CSS knowledge, please visit the CSS Video Tutorial column!
The above is the detailed content of How to introduce css into jsp. For more information, please follow other related articles on the PHP Chinese website!