HTML: Καθορισμός κωδικών χρώματος - πώς λειτουργεί
Μπορείτε να ορίσετε χρώματα σε HTML με διαφορετικούς τρόπους. Σας παρουσιάζουμε πώς να το κάνετε αυτό.
Ορίστε τους κωδικούς χρωμάτων σε HTML
Βασικά, μπορείτε να ορίσετε χρώματα σε HTML με δύο τρόπους - είτε με ονόματα χρωμάτων είτε με hexcodes. Τα ονόματα χρωμάτων είναι πιο αξέχαστα, αλλά οι περισσότεροι προγραμματιστές Ιστού χρησιμοποιούν hexcodes για να κωδικοποιήσουν τα χρώματα:
- Δευτερεύων κωδικός: Ο δεκαεξαδικός αριθμός έχει πάντα έξι ψηφία για την κωδικοποίηση των χρωμάτων. Τα δύο πρώτα ψηφία αντιπροσωπεύουν το κόκκινο συστατικό, τα επόμενα δύο πράσινα και τα δύο τελευταία για το μπλε συστατικό. Υπάρχει πάντα ένα σημάδι διαμαντιού μπροστά από ένα χρώμα: "#". Έτσι μπορείτε να ορίσετε ένα κόκκινο χρώμα φόντου όπως αυτό: "". Λάβετε υπόψη ότι η ορθογραφία είναι ξεπερασμένη χωρίς φύλλα στυλ. Για παράδειγμα, αποφύγετε αυτόν τον κωδικό: "".
- Ονόματα χρωμάτων: Βασικά λειτουργούν με τον ίδιο τρόπο όπως και οι δεκαεξαδικοί κωδικοί. Θα μπορούσατε να δημιουργήσετε ένα κόκκινο φόντο όπως αυτό: "". Μπορείτε να βρείτε λεπτομερείς πίνακες με εκατοντάδες ονόματα χρωμάτων στο Internet.
Είναι πιο επαγγελματικό να μεταφέρετε τους ορισμούς χρωμάτων σε ένα εξωτερικό φύλλο στυλ (CSS). Σε μια άλλη πρακτική συμβουλή, εξηγούμε τις διαφορές μεταξύ HTML και CSS.