Home > Java > javaTutorial > body text

How to reference css in jsp

(*-*)浩
Release: 2019-05-24 13:44:05
Original
11850 people have browsed it

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!

In software engineering, when I was doing Web front-end development and writing jsp pages, I felt that the pages were very ugly. My classmates introduced me to the problem of inserting css to improve the beauty of the pages.

Recommended course: Java Tutorial.

How to reference css in jsp

How to introduce the css style sheet file into the jsp page?

First put the written css style sheet content Save as *.css format. For example, style.css
Introduce this css style file into the page. Introduce it in the following way.

<link rel="stylesheet" href="./css/style.css" type="text/css">
Copy after login

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.

By the way, let’s talk about how to write css styles in JSP pages.

Internal styles

When a single document requires special styles, internal style sheets should be used. Internal style sheets can be defined at the head of the document using the