Σε αυτό το κεφάλαιο θα μάθετε για τις ακόλουθες ιδιότητες:
text-decoration-line
text-decoration-color
text-decoration-style
text-decoration-thickness
text-decoration
Η ιδιότητα text-decoration-line
χρησιμοποιείται για την προσθήκη μια διακοσμητική γραμμή σε κείμενο.
Συμβουλή: Μπορείτε να συνδυάσετε περισσότερες από μία τιμές, όπως overline και υπογράμμιση για εμφάνιση γραμμών πάνω και κάτω από ένα κείμενο.
h1 {
text-decoration-line: overline;
}
h2 {
text-decoration-line: line-through;
}
h3 {
text-decoration-line: underline;
}
p {
text-decoration-line:
overline underline;
}
Δοκιμάστε το μόνοι σας →
<!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>
Σημείωση: Δεν συνιστάται η υπογράμμιση κειμένου που δεν είναι σύνδεσμος, καθώς αυτό συχνά προκαλεί σύγχυση στον αναγνώστη.
Η ιδιότητα text-decoration-color
χρησιμοποιείται για ορίστε το χρώμα της γραμμής διακόσμησης.
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;
}
Δοκιμάστε το μόνοι σας →
<!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>
Η ιδιότητα text-decoration-style
χρησιμοποιείται για ορίστε το στυλ της γραμμής διακόσμησης.
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;
}
Δοκιμάστε το μόνοι σας →
<!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>
Η ιδιότητα text-decoration-thickness
χρησιμοποιείται για ορίστε το πάχος της γραμμής διακόσμησης.
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;
}
Δοκιμάστε το μόνοι σας →
<!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>
Η ιδιότητα text-decoration
είναι συντομογραφία ιδιοκτησία για:
text-decoration-line
(απαιτείται)
text-decoration-color
(προαιρετικό)
text-decoration-style
(προαιρετικό)
πάχος διακόσμησης κειμένου
(προαιρετικό)
h1 {
text-decoration: underline;
}
h2 {
text-decoration: underline red;
}
h3 {
text-decoration: underline
red double;
}
p {
text-decoration: underline red double 5px;
}
Δοκιμάστε το μόνοι σας →
<!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>
Όλοι οι σύνδεσμοι σε HTML είναι υπογραμμισμένοι από προεπιλογή. Μερικές φορές εσύ δείτε ότι οι σύνδεσμοι έχουν στυλ χωρίς υπογράμμιση. Το text-decoration: none;
χρησιμοποιείται για την αφαίρεση η υπογράμμιση από τους συνδέσμους, σαν αυτό:
a {
text-decoration: none;
}
Δοκιμάστε το μόνοι σας →
<!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>
Ορίζει όλες τις ιδιότητες διακόσμησης κειμένου σε μία δήλωση
Καθορίζει το χρώμα του κειμένου-διακόσμησης
Καθορίζει το είδος της διακόσμησης κειμένου που θα χρησιμοποιηθεί (υπογράμμιση, υπεργράμμιση, και τα λοιπά.)
Καθορίζει το στυλ της διακόσμησης του κειμένου (συμπαγής, διακεκομμένη, κ.λπ.)
Καθορίζει το πάχος της γραμμής διακόσμησης κειμένου