Setting HEX as the default color code for input type="color"

Donald Symmons 2,881 Reputation points
2024-02-19T10:17:42.52+00:00

Hi, Please a there a way that I can make HEX be the default color code for input type = "color"? As it is, when I click on the input color, it is the RGB that show first, then using the "up and down" scroll arrow it changes to HSL, and then HEX. Does the "RGB > HSL > HEX" come be default that cannot be changed?

<div class="row" runat="server" id="PortraitColor">
     <div class="col-md-12">
         <div class="form-group">
             <label runat="server" id="Label19">Font color</label>
             <div class="input-group">
                   <input type="color" runat="server" class="fonts form-control" id="color" onchange="LabelColor()" />
             </div>
         </div>
     </div>
 </div>

<script type="text/javascript">
    function LabelColor() {
       
        document.getElementById("GridParent").style.color = document.getElementById("color").value;
    }
</script>

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,877 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,494 questions
0 comments No comments
{count} votes

Accepted answer
  1. Lan Huang-MSFT 29,591 Reputation points Microsoft Vendor
    2024-02-20T01:35:55.4433333+00:00

    Hi @Donald Symmons,

    You can't make it only display hex, but whatever mode the user chooses the value is stored as hex. User's image

    document.getElementById("color").value = "#ff0000"

    Best regards,
    Lan Huang


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.