<body>
<div style="width: 65pxheight: 20pxborder: 1px solid">测试元素</div>
</body>
三中的使用方法的简单实例如下:
行内样式:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>css行内样式</title>
</head>
<body>
<div style="width:100pxheight:100pxbackground:red"></div>>
</body>
</html>
内嵌样式:
!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>css内嵌样式</title>
</head>
<body>
<style type="text/css">
#div{width:100pxheight:100pxbackground:red}
</style>
<div id="div"></div>>
</body>
</html>
外部式:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>css内嵌样式</title>
<link rel="stylesheet" type="text/css" href="ccss.css">
</head>
<body>
<div id="div"></div>>
</body>
</html>
css文件
#div{width:100pxheight:100pxbackground:red}
拓展资料:
三中的使用方法的简单实例如下:
行内样式:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>css行内样式</title>
</head>
<body>
<div style="width:100pxheight:100pxbackground:red"></div>>
</body>
</html>
内嵌样式:
!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>css内嵌样式</title>
</head>
<body>
<style type="text/css">
#div{width:100pxheight:100pxbackground:red}
</style>
<div id="div"></div>>
</body>
</html>
外部式:
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>css内嵌样式</title>
<link rel="stylesheet" type="text/css" href="ccss.css">
</head>
<body>
<div id="div"></div>>
</body>
</html>
css文件
#div{width:100pxheight:100pxbackground:red}
简言之:
行内样式:就是代码写在具体网页中的一个元素内;比如:<div style="color:#f00"></div>
内嵌式:就是在</head>前面写;比如:<style type="text/css">.div{color:#F00}</style>
外部式:就是引用外部css文件;比如:<link href="css.css" type="text/css" rel="stylesheet" />