Short answer
A CNAME aliases one domain name to another, and a TXT record holds text. They are not interchangeable. RFC 1035 numbers CNAME as type 5 and TXT as type 16. RFC 1034 says that if a CNAME is present at a name, no other data should be present there. TXT is how a zone stores a string, including the tokens some services ask you to publish. Replacing one with the other breaks the job the first record was doing.
Last verified against the sources listed below.
Key takeaways
- CNAME type 5 stores the canonical name of an alias. TXT type 16 stores text strings.
- If a CNAME exists at a name, RFC 1034 says no other data should be present.
- TXT semantics depend on the domain. The record itself is only the characters.
- Cloudflare limits a name's labels to 63 characters and the full name to 253.
- Search Console may ask for TXT or CNAME during domain checks. That does not make the types identical.
- IANA's DNS registry, updated December 1, 2026, still lists those two type numbers.
The txt record vs cname question has a short answer: one record stores text, and the other aliases a name. They are not two labels for the same DNS data, and you cannot swap them and keep the old behavior.
Web hosting is where the site runs. DNS is how a name reaches that host, or how you publish a string a vendor asked for. CNAME is the alias. TXT is the string.
What does a CNAME record store?
A CNAME stores the canonical name of an alias, and the owner name should not carry other records.
RFC 1034, section 3.6.2, says a CNAME resource record identifies its owner name as an alias and puts the corresponding canonical name in the record data. If a CNAME is present at a node, no other data should be present. The text gives two reasons: the canonical name and the alias must not disagree, and a cached CNAME can be reused without a fresh lookup for other types.
When a server does not find the type you asked for, and the name has a CNAME of the same class, it returns the CNAME and restarts the query at the canonical name. A query that asked for type CNAME itself is the exception and is not restarted. Chains should be followed. Loops should not make the software fail, which is the RFC’s instruction to implementers, not a suggestion to publish a loop.
What does a TXT record store?
A TXT record stores one or more character strings, and the meaning of those strings is defined by whoever asked you to publish them.
RFC 1035 gives CNAME the type value 5, “the canonical name for an alias,” and TXT the type value 16, “text strings.” The TXT RDATA is one or more character strings. The RFC says TXT records hold descriptive text, and that the semantics depend on the domain where the record is found.
The type does not know whether the text is a note, a verification token, or something else. The publisher and the reader agree on the meaning outside the type code.
IANA’s DNS parameters, updated December 1, 2026, still list CNAME as 5 and TXT as 16, with the same short meanings, both traced to RFC 1035. The numbers have not been reassigned.
How do the two records compare?
They differ in type number, in payload, and in whether other data may share the owner name.
| CNAME | TXT | |
|---|---|---|
| Type value | 5 | 16 |
| Payload | A domain name, the canonical name | One or more character strings |
| Other data at that name | Should not be present, per RFC 1034 | Allowed, because the CNAME rule is about CNAME |
| What a lookup is for | Alias this name to another name | Read the text published at this name |
| Cloudflare’s common use | Point a name at a target hostname | Show control of a domain before a certificate |
Cloudflare’s record reference says a CNAME maps a domain name to another, canonical, domain name, and that it can be used to resolve other record types present on the target. Labels are 63 characters or fewer. The fully qualified name does not exceed 253 characters. The page recommends letters, digits, and hyphens for names that will also appear in certificates, and it says that advice is for compatibility, not a protocol ban on other bytes.
For TXT, Cloudflare says the content is one or more strings delimited by double quotes. A mismatched quote can fail validation. If you save a new record with no quotes, Cloudflare adds the double quotes.
On that platform, TXT is most often used to prove domain control before an SSL or TLS certificate is issued. The page also mentions mail authentication text and points people at Cloudflare’s own email wizard rather than a hand-built string. This guide does not expand that mail case.
When does Search Console ask for one or the other?
Search Console picks TXT or CNAME from the records that already exist, and the two instructions are not substitutes after that choice.
The help page says a domain property is verified by adding a DNS record at the provider. You choose Domain name provider on the ownership page, then you determine the format. The most common case, if no CNAME is found, is the TXT instructions.
If a CNAME is found and the target is a parent domain of the name you typed, you follow the CNAME instructions. If that name is not a parent, you use TXT.
Search Console generates the TXT value when you choose TXT as the record type. You copy that string, and you do not invent a CNAME target and expect the same check to pass. The help page is choosing a verification method.
RFC 1034 is still the rule for what a CNAME means on the name where you place it.
What mistake treats them as the same field?
The mistake is deleting a CNAME to paste in a TXT, or putting a token on a name that is already an alias.
An alias that disappears will stop resolving to the canonical host. A text token published where a CNAME used to be does not restore that hop. The opposite mistake is to publish the verification string as a CNAME target.
A target has to be a domain name. A long token is text, which is what type 16 is for.
The coexistence mistake is quieter. RFC 1034’s “no other data” line means a TXT on the alias’s owner name is the wrong shelf. Publish the text at the canonical name, or at a dedicated name such as the one the vendor’s instructions specify. Then leave the alias as an alias.
A favicon generator makes the icon for the site. The icon is not a DNS record. After the file exists, the name visitors type still needs an address or an alias, and any proof a certificate vendor wants still needs the text record they specified. Those are separate rows in the zone, with separate type numbers, 5 and 16.
Frequently asked questions
What is the difference between a TXT record and a CNAME?
A CNAME identifies its owner name as an alias and stores the canonical name in the record data. A TXT record stores one or more character strings, and RFC 1035 says those strings are descriptive text whose meaning depends on the domain where you find them. Type numbers from that RFC, and from IANA's registry, are 5 for CNAME and 16 for TXT. You can publish both types in one zone. You should not publish them as if they were the same field with two labels.
Can a name have a CNAME and a TXT record?
RFC 1034 says that if a CNAME is present at a node, no other data should be present. The reason given is so the canonical name and its aliases cannot disagree, and so a cache can use the CNAME without asking an authoritative server about other types. A TXT record is other data. Putting it on the same owner name as a CNAME breaks that rule. Put the TXT record on the canonical name, or on a different owner name, such as a host you are verifying.
Why do some setups ask for either TXT or CNAME?
Search Console's domain check can use either record, and it tells you which one from the DNS you have. If no CNAME is found, add the TXT record it generated. If a CNAME is found and its target is a parent domain of the name you entered, follow the CNAME instructions. If the target is not a parent, use TXT. That is a choice of verification method. It does not mean a text token will alias a hostname, or that an alias will satisfy a checker that asked for text.
How long can a CNAME name be at Cloudflare?
Cloudflare's DNS record page says each label in the name is 63 characters or fewer, and the fully qualified name does not exceed 253 characters. The target is another hostname. The page recommends letters, digits, and hyphens when the name will also be used as a hostname or on a certificate, and it notes that this recommendation is not a DNS protocol requirement. Underscores are valid in DNS. Those lengths are Cloudflare's field rules for the name, not a limit on how long a TXT string may be.
Does a TXT record point a website at a host?
No. A TXT record holds text. It does not store the canonical name of an alias, which is the CNAME's job, and it does not store an address by itself. Cloudflare says TXT records there are most often used to demonstrate that you control a domain before a certificate is issued. Some mail checks also use text records, but the type is still text. To send visitors to a site, you need an address record or an alias, not a verification string.
Sources
- Domain names, concepts and facilities · RFC Editor, 1987
- Domain names, implementation and specification · RFC Editor, 1987
- Domain Name System (DNS) Parameters · IANA, 2026
- DNS record types · Cloudflare, 2026
- Verify your site ownership · Google Search Console Help, 2026