HTML Style Tags
CSS stands for Cascading Style Sheets.
CSS describes how HTML elements are to be displayed on screen, paper, or in other media.
CSS saves a lot of work. It can control the layout of multiple web pages all at once.
CSS can be added to HTML elements in 3 ways:
- Inline - by using the style attribute in HTML elements
- Internal - by using a <style> element in the <head> section
- External - by using an external CSS file
Tag | Description |
---|---|
<style> | Defines style information for an HTML document |
<link> | Defines a link between a document and an external resource |
- Use the HTML style attribute for inline styling
- Use the HTML <style> element to define internal CSS
- Use the HTML <link> element to refer to an external CSS file
- Use the HTML <head> element to store <style> and <link> elements
- Use the CSS color property for text colors
- Use the CSS font-family property for text fonts
- Use the CSS font-size property for text sizes
- Use the CSS border property for borders
- Use the CSS padding property for space inside the border
- Use the CSS margin property for space outside the border
-
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Creating a bookmark</title>
</head>
<body>
<
<a href="#tips">Visit the useful Tips Section</a>
<h2>Chapter 1</h2>
<p>This chapter explains ba bla bla</p> <h2>Chapter 2</h2>
<p>This chapter explains ba bla bla</p> <h2>Chapter 3</h2>
<p>This chapter explains ba bla bla</p> <h2 >Chapter 4</h2>
<p>This chapter explains ba bla bla</p> <h2>Chapter 5</h2>
<p>This chapter explains ba bla bla</p> <h2>Chapter 6</h2>
<p>This chapter explains ba bla bla</p> <h2>Chapter 7</h2>
<p>This chapter explains ba bla bla</p> <h2>Chapter 8</h2>
<p>This chapter explains ba bla bla</p> <h2>Chapter 9</h2>
<p>This chapter explains ba bla bla</p> <h2>Chapter 10</h2>
<p>This chapter explains ba bla bla</p> <h2 id="tips">Chapter 11</h2>
<p>This chapter explains ba bla bla</p> <h2>Chapter 12</h2>
<p>This chapter explains ba bla bla</p> <h2>Chapter 13</h2>
<p>This chapter explains ba bla bla</p> <h2>Chapter 14</h2>
<p>This chapter explains ba bla bla</p> <h2>Chapter 15</h2>
<p>This chapter explains ba bla bla</p> <h2>Chapter 16</h2>
<p>This chapter explains ba bla bla</p> <h2>Chapter 17</h2>
<p>This chapter explains ba bla bla</p>
</body>
</html><!DOCTYPE html>
<html lang="en">
<head>
<style>
body{background-color: #b3d4fc}
h1{color: blue;
font-family: "Arial Black";
font-size: 300%}
#p01{
background-color: blueviolet;
border: 5px solid blue;<!-- 定义边界宽度和颜色-->
padding: 14px;<!-- 定义文字和边界之间的距离-->
margin: 40 px;<!-- 定义边界外的文字文字和边界之间的距离-->
color: red; font-size: 200%;
font-family: "Arial Black"}
p.info{
background-color: yellow;
color: rebeccapurple;
font-size: 200px;
}
#a01:link{<!--定义了连接正常的显示样式-->
color: yellowgreen;
text-decoration: none;
}
#a01:hover{<!--定义了鼠标位于连接上方时候的显示样式-->
color: yellow;
background-color: transparent;
text-decoration: underline;
} </style>
<meta charset="UTF-8">
<title>Color</title>
</head> <body> <h1 style="background-color: red"> <a id="a01" href="http://www.snowfox.wang/w3schools" target="_blank">
This is a link to a website on the World Wide Web</a> </h1><!--href为增加超链接的标志,blank为重新打开一个窗口-->
<h1 style="background-color: orange"><a href="2-Formating.html" target="_blank">Using the local link </a></h1>
<h1 style="background-color: yellow">Background-color set by using yellow</h1>
<h1 style="background-color: blue;color:red;" >Background-color set by using blue</h1>
<p id="p01"<!--定义一个特殊的ID以区别其他的paragraph-->Hello everyone, I am JackSparrow and I am from Anhui Province</p>
<p class="info">天天向上,好好学习</p> <p> Hello everyone, I am JackSparrow and I am from Anhui Province</p>
</body>
</html>