CSS的书写位置

让我为大家介绍一下css的书写位置

1.内部

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>内部</title>
    <!-- 内部位置 -->
    <!-- 这就是内部形式 -->
    <style>
        div {
            width: 100px;
            height: 100px;
        }
    </style>
</head>
<body>
    <div>1</div>
    <div>2</div>
    <div>3</div>
</body>
</html>

2.外部

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>外部</title>
    <!-- 这是外部形式,也是开发中最常用的 -->
    <link rel="stylesheet" href="index.css">
</head>
<body>
    <div>1</div>
    <div>2</div>
    <div>3</div>
</body>
</html>

3.行内

html 复制代码
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>行内</title>
</head>
<body>
    <!-- 行内加style -->
    <div style="width: 200px;height: 200px;">1</div>
</body>
</html>

感谢大家的阅读,如有不对的地方,可以向我提出,感谢大家!

相关推荐
|晴 天|34 分钟前
Vue 3 + TypeScript + Element Plus 博客系统开发总结与思考
前端·vue.js·typescript
猫3281 小时前
v-cloak
前端·javascript·vue.js
旷世奇才李先生1 小时前
Vue 3\+Vite\+Pinia实战:企业级前端项目架构设计
前端·javascript·vue.js
SoaringHeart3 小时前
Flutter进阶:用OverlayEntry 实现所有弹窗效果
前端·flutter
IT_陈寒5 小时前
Vite静态资源加载把我坑惨了
前端·人工智能·后端
herinspace5 小时前
管家婆实用贴-如何分离和附加数据库
开发语言·前端·javascript·数据库·语音识别
小码哥_常5 小时前
从MVC到MVI:一文吃透架构模式进化史
前端
嗷o嗷o5 小时前
Android BLE 的 notify 和 indicate 到底有什么区别
前端
豹哥学前端5 小时前
别再背“var 提升,let/const 不提升”了:揭开暂时性死区的真实面目
前端·面试
lar_slw6 小时前
k8s部署前端项目
前端·容器·kubernetes