jsp文件中如何引用css文件

html-css010

jsp文件中如何引用css文件,第1张

<meta http-equiv="pragma" content="no-cache">

<meta http-equiv="cache-control" content="no-cache">

<meta http-equiv="expires" content="0">

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">

<meta http-equiv="description" content="This is my page">

<!--

<link rel="stylesheet" type="text/css" href="styles.css">

-->

<link rel="stylesheet" type="text/css" href="<%=basePath%>css/so1.css">

<link rel="stylesheet" type="text/css" href="<%=basePath%>css/so2.css">

<link rel="stylesheet" type="text/css" href="<%=basePath%>css/so3.css">

<script type="text/javascript" src="<%=basePath%>js/jquery-2.0.2.min.js"></script>

<script type="text/javascript" src="<%=basePath%>js/mov.js"></script>

在jsp中加入css样式,就跟html加入的方式一样,具体有以下三种方式:

1、 外部样式

当样式需要应用于很多页面时,外部样式表将是理想的选择。在使用外部样式表的情况下,你可以通过改变一个文件来改变整个站点的外观。每个页面使用<link>标签链接到样式表。<link>标签在(文档的)头部:

<head>

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

</head>

2、内部样式

当单个文档需要特殊的样式时,就应该使用内部样式表。可以使用<style>标签在文档头部定义内部样式表。

<head>

<style type="text/css">

样式

</style>

</head>

3、内联样式

当样式仅需要在一个元素上应用一次时, 要使用内联样式,你需要在相关的标签内使用样式(style)属性。Style属性可以包含任何CSS属性。由于要将表现和内容混杂在一起,内联样式会损失掉样式表的许多优势。请慎用这种方法

<div style="width:100px"></div>

内联样式的优先级最高,其次是内部样式,外部样式的优先级是最低的。