CSS szöveg díszítés


Tartalomjegyzék

    Tartalomjegyzék megjelenítése


Szöveg dekoráció

Ebben a fejezetben a következő tulajdonságokat ismerheti meg:

  • text-decoration-line
  • text-decoration-color
  • text-decoration-style
  • text-decoration-thickness
  • text-decoration

Adjon hozzá dekorációs sort a szöveghez

A hozzáadáshoz a text-decoration-line tulajdonság szolgál díszítő sor a szöveghez.

Tipp: Egynél több értéket kombinálhat, például overline és aláhúzás a szöveg feletti és alatti sorok megjelenítéséhez.

Példa

h1 {
  text-decoration-line: overline;
}

h2 {
  text-decoration-line: line-through;
}

h3 {
  text-decoration-line: underline;
}
p {
  text-decoration-line: 
  overline underline;
}

Próbálja ki Ön is →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-decoration: overline;
}

h2 {
  text-decoration: line-through;
}

h3 {
  text-decoration: underline;
}

p.ex {
  text-decoration: overline underline;
}
</style>
</head>
<body>

<h1>Overline text decoration</h1>
<h2>Line-through text decoration</h2>
<h3>Underline text decoration</h3>
<p class="ex">Overline and underline text decoration.</p>

<p><strong>Note:</strong> It is not recommended to underline text that is not a link, as this often confuses 
the reader.</p>

</body>
</html>


Megjegyzés: Nem ajánlott olyan szöveget aláhúzni, amely nem hivatkozás, mivel ez gyakran megzavarja az olvasót.


Adjon meg egy színt a dekorációs vonalhoz

A text-decoration-color tulajdonságot használják állítsa be a dekorációs vonal színét.

Példa

h1 {
  text-decoration-line: overline;
  text-decoration-color: 
  red;
}

h2 {
  text-decoration-line: line-through;
  text-decoration-color: 
  blue;
}

h3 {
  text-decoration-line: underline;
  text-decoration-color: 
  green;
}
p {
  text-decoration-line: 
  overline underline;
  text-decoration-color: purple;
}

Próbálja ki Ön is →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-decoration-line: overline;
  text-decoration-color: red;
}

h2 {
  text-decoration-line: line-through;
  text-decoration-color: blue;
}

h3 {
  text-decoration-line: underline;
  text-decoration-color: green;  
}

p {
  text-decoration-line: overline underline;
  text-decoration-color: purple;  
}
</style>
</head>
<body>

<h1>Overline text decoration</h1>
<h2>Line-through text decoration</h2>
<h3>Underline text decoration</h3>
<p>Overline and underline text decoration.</p>

</body>
</html>




Adjon meg egy stílust a dekorációs vonalhoz

A text-decoration-style tulajdonságot arra használják, hogy állítsa be a dekorációs vonal stílusát.

Példa

 h1 {
  text-decoration-line: underline;
  text-decoration-style: 
  solid;
}
  
h2 {
  text-decoration-line: underline;
  
  text-decoration-style: double;
}
  
h3 {
  text-decoration-line: underline;
  
  text-decoration-style: dotted; 
}
p.ex1 {
  text-decoration-line: underline;
  
  text-decoration-style: dashed; 
}
p.ex2 {
  text-decoration-line: underline;
  
  text-decoration-style: wavy; 
}
p.ex3 {
  text-decoration-line: 
  underline;
  text-decoration-color: red; 
  
  text-decoration-style: wavy; 
}

Próbálja ki Ön is →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-decoration-line: underline;
  text-decoration-style: solid; /* this is default */
}

h2 {
  text-decoration-line: underline;
  text-decoration-style: double;
}

h3 {
  text-decoration-line: underline;
  text-decoration-style: dotted;  
}

p.ex1 {
  text-decoration-line: underline;
  text-decoration-style: dashed;  
}

p.ex2 {
  text-decoration-line: underline;
  text-decoration-style: wavy;  
}

p.ex3 {
  text-decoration-line: underline;
  text-decoration-color: red;  
  text-decoration-style: wavy;  
}
</style>
</head>
<body>

<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<p class="ex1">A paragraph.</p>
<p class="ex2">Another paragraph.</p>
<p class="ex3">Another paragraph.</p>

</body>
</html>



Adja meg a dekorációs vonal vastagságát

A text-decoration-thickness tulajdonság arra szolgál, hogy állítsa be a díszítővonal vastagságát.

Példa

 h1 {
  text-decoration-line: underline;
  
  text-decoration-thickness: auto;
}
h2 {
  text-decoration-line: 
  underline;
  text-decoration-thickness: 5px;
}
h3 {
  
  text-decoration-line: underline;
  text-decoration-thickness: 25%;
  }
p {
  
  text-decoration-line: underline;
  text-decoration-color: red; 
  
  text-decoration-style: double;
  text-decoration-thickness: 5px; 
}

Próbálja ki Ön is →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-decoration-line: underline;
  text-decoration-thickness: auto;  /* this is default */
}

h2 {
  text-decoration-line: underline;
  text-decoration-thickness: 5px;
}

h3 {
  text-decoration-line: underline;
  text-decoration-thickness: 25%;
}

p {
  text-decoration-line: underline;
  text-decoration-color: red;  
  text-decoration-style: double;
  text-decoration-thickness: 5px;  
}
</style>
</head>
<body>

<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<p>A paragraph.</p>

</body>
</html>



A gyorsírási ingatlan

A text-decoration tulajdonság egy rövidítés ingatlan részére:

  • text-decoration-line (kötelező)

  • text-decoration-color (opcionális)

  • text-decoration-style (opcionális)

  • text-decoration-thickness (opcionális)

Példa

 h1 {
  text-decoration: underline;
}
h2 {
  
  text-decoration: underline red;
}
h3 {
  text-decoration: underline 
  red double;
}
p {
  
  text-decoration: underline red double 5px;
}

Próbálja ki Ön is →

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
  text-decoration: underline;
}

h2 {
  text-decoration: underline red;
}

h3 {
  text-decoration: underline red double;
}

p {
  text-decoration: underline red double 5px;
}
</style>
</head>
<body>

<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<p>A paragraph.</p>

</body>
</html>



Egy kis tipp

A HTML-ben minden hivatkozás alapértelmezés szerint alá van húzva. Néha te nézze meg, hogy a hivatkozások stílusa aláhúzás nélkül történik. A text-decoration: none; az eltávolításra szolgál az aláhúzás a linkekből, mint ez:

Példa

a {
  text-decoration: none;
}

Próbálja ki Ön is →

<!DOCTYPE html>
<html>
<head>
<style>
a {
  text-decoration: none;
}
</style>
</head>
<body>

<h1>Using text-decoration: none</h1>

<p>A link with no underline: <a href="https://www.w3schools.com">W3Schools.com</a></p>

</body>
</html>



Minden CSS-szövegdekorációs tulajdonság

text-decoration

Az összes szövegdíszítési tulajdonságot egyetlen deklarációban állítja be

text-decoration-color

Meghatározza a szövegdekoráció színét

text-decoration-line

Meghatározza a használandó szövegdíszítés típusát (aláhúzás, áthúzás, stb.)

text-decoration-style

Meghatározza a szöveg díszítésének stílusát (egyszínű, pontozott stb.)

text-decoration-thickness

Meghatározza a szövegdíszítési vonal vastagságát