앱 만들기/CSS

CSS 컬러 (백그라운드, 텍스트)

나도 처음이야 2023. 7. 12.
반응형

배경 색상과 텍스트 색상은 CSS 컬러로 가장 많이 설정하는 속성입니다.
예제를 만들어봅니다.
CSS 선언부에서 h1과 p  요소(element)를 위한 스타일을 선언합니다.
color : 컬러값  >> 텍스트 컬러를 설정합니다
background-color : 컬러값 >> 배경 컬러를 설정합니다.

 <title>CSS Colors</title>
    <style>
      h1{
        color:blueviolet;
        background-color: aqua;
      }
      p{
        color:brown;
        background-color: yellowgreen;
      }
    </style>
</head>

h1, p 태그 콘텐츠를 완성합니다.

<body> 
  <h1>Hello world!</h1>
  <p>What is Lorem Ipsum?
    Lorem Ipsum is simply dummy text of the printing and typesetting industry. 
    Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, 
    when an unknown printer took a galley of type and scrambled it to make a type specimen book. 
    It has survived not only five centuries, 
    but also the leap into electronic typesetting, remaining essentially unchanged. 
    It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, 
    and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>
</body>

웹페이지에서 실행한 결과는 하기와 같습니다.
color로는 텍스트 색상을
background-color 속성으로는 배경 색상을 설정할 수 있습니다.

color / background-color 속성 예제

 
참고로, 컬러의 속성값을 컬러 이름으로 설정할 수 있습니다.
모든 브라우저에 140개의 색상을 지원합니다. 필요한 컬러값은 검색해서 사용하면 됩니다.

W3 school에서 제공하는 컬러네임 페이지를 참고 드립니다.
오늘은 CSS 컬러 중  많이 사용되는 속성인 color와 background-color에 대해서 알아보았습니다
감사합니다.
 

HTML Color Names

W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.

www.w3schools.com

 

반응형

댓글

💲 추천 글