<link href="style.css" type="text/css" rel="stylesheet">
<p style="color: red; font-size: 20px;">I'm learning to code!</p>
=>html에서 태그 안에 style 속성으로 스타일 입히는 것
<head>
<style>
p {
color: red;
font-size: 20px;
}
</style>
</head>
- href — like the anchor element, the value of this attribute must be the address, or path, to the CSS file.
- type — this attribute describes the type of document that you are linking to (in this case, a CSS file). The value of this attribute should be set to text/css.
- rel — this attribute describes the relationship between the HTML file and the CSS file. Because you are linking to a stylesheet, the value should be set to stylesheet.
<link href="style.css" type="text/css" rel="stylesheet">
p {
}
.brand {
}
.green {
color: green;
}
.bold {
font-weight: bold;
}
<h1 class="green bold"> ... </h1>
#large-title {
}
browser decides which CSS styles will be displayed.
IDs are the most specific selector in CSS,
followed by classes, and finally, tags.
For example, consider the following HTML and CSS:
h1 {
color: red;
}
.headline {
color: firebrick;
여러가지 클래스에 한번에 속성 먹이고 싶을 때 한번에 적용시키기 가능
it’s possible to require an HTML element to have two or more CSS selectors at the same time.
This is done by combining multiple selectors, which we will refer to as chaining.
h1.special {
}
CSS also supports selecting elements that are nested within other HTML elements
어떤 클래스,태그,아이디 밑의 속성 콕 찝어서 css적용 가능
<ul class='main-list'>
<li> ... </li>
<li> ... </li>
<li> ... </li>
</ul>
.main-list li {
}
p {
color: blue;
}
.main p {
color: red;
}
p 모두 파랑으로 나온다, except main에 있는 p
to make CSS more concise, it’s possible to add CSS styles to multiple CSS selectors all at once. This prevents writing repetitive code.
여러 클래스와, 태그, 아이디 한번에 써놓고 css한번에 때려넣기 가능
h1 {
font-family: Georgia;
}
.menu {
font-family: Georgia;
}
===>
h1,
.menu {
font-family: Georgia;
}