ایچ تی ایم ال کلاس

对 HTML 进行分类(设置类),使我们能够为元素的类定义 CSS 样式。

为相同的类设置相同的样式,或者为不同的类设置不同的样式。

ਉਦਾਹਰਣ

<!DOCTYPE html>
<html>
<head>
<style>
.cities {
    background-color:black;
    color:white;
    margin:20px;
    padding:20px;
} 
</style>
</head>
<body>
<div class="cities">
<h2>London</h2>
<p>
London is the capital city of England. 
ਇਹ ਬ੍ਰਿਟੇਨ ਵਿੱਚ ਸਭ ਤੋਂ ਅਬਾਦੀ ਵਾਲਾ ਸ਼ਹਿਰ ਹੈ, 
with a metropolitan area of over 13 million inhabitants.
</p>
</div> 
</body>
</html>

ਆਪਣੇ ਅਨੁਸਾਰ ਕੋਸ਼ਿਸ਼ ਕਰੋ

分类块级元素

HTML <div> 元素是块级元素。它能够用作其他 HTML 元素的容器。

设置 <div> 元素的类,使我们能够为相同的 <div> 元素设置相同的类:

ਉਦਾਹਰਣ

<!DOCTYPE html>
<html>
<head>
<style>
.cities {
    background-color:black;
    color:white;
    margin:20px;
    padding:20px;
} 
</style>
</head>
<body>
<div class="cities">
<h2>London</h2>
<p>London is the capital city of England. 
ਇਹ ਬ੍ਰਿਟੇਨ ਵਿੱਚ ਸਭ ਤੋਂ ਅਬਾਦੀ ਵਾਲਾ ਸ਼ਹਿਰ ਹੈ, 
13 ਮਿਲੀਅਨ ਤੋਂ ਵੱਧ ਅਬਾਦੀ ਵਾਲਾ ਮੈਟਰੋਪੋਲੀਟਨ ਇਲਾਕਾ ਹੈ。</p>
</div>
<div class="cities">
<h2>ਪੈਰਿਸ</h2>
<p>ਪੈਰਿਸ ਫਰਾਂਸ ਦੀ ਰਾਜਧਾਨੀ ਅਤੇ ਸਭ ਤੋਂ ਅਬਾਦੀ ਵਾਲਾ ਸ਼ਹਿਰ ਹੈ。</p>
</div>
<div class="cities">
<h2>ਟੋਕੀਓ</h2>
<p>ਟੋਕੀਓ ਜਪਾਨ ਦੀ ਰਾਜਧਾਨੀ, ਗ੍ਰੇਟਰ ਟੋਕੀਓ ਇਲਾਕੇ ਦਾ ਕੇਂਦਰ ਹੈ,</p>
ਅਤੇ ਦੁਨੀਆ ਵਿੱਚ ਸਭ ਤੋਂ ਅਬਾਦੀ ਵਾਲਾ ਮੈਟਰੋਪੋਲੀਟਨ ਇਲਾਕਾ ਹੈ。</p>
</div>
</body>
</html>

ਆਪਣੇ ਅਨੁਸਾਰ ਕੋਸ਼ਿਸ਼ ਕਰੋ

ਵਰਗੀਕ੍ਰਿਤ ਰੈਕਾਰਡ ਇਲਾਕਾ

HTML <span> ਅਲੌਕਨ ਇੱਕ ਰੈਕਾਰਡ ਇਲਾਕਾ ਹੈ, ਇਹ ਟੈਕਸਟ ਦੇ ਕੰਟੇਨਰ ਵਜੋਂ ਵਰਤਿਆ ਜਾ ਸਕਦਾ ਹੈ。

ਸੈਟ <span> ਅਲੌਕਨ ਦੀ ਕਲਾਸ, ਇੱਕ ਹੀ ਕਲਾਸ ਵਾਲੇ <span> ਅਲੌਕਨ ਲਈ ਇੱਕ ਹੀ ਸਟਾਈਲ ਸੈਟ ਕਰ ਸਕਦੇ ਹਨ。

ਉਦਾਹਰਣ

<!DOCTYPE html>
<html>
<head>
<style>
  span.red {color:red;}
</style>
</head>
<body>
<h1>My <span class="red">Important</span> Heading</h1>
</body>
</html>

ਆਪਣੇ ਅਨੁਸਾਰ ਕੋਸ਼ਿਸ਼ ਕਰੋ