Ports are provided by services.
General DNS resolves domain names, which are composed of various records, such as A record, NS record, MX record and CNAME record. The A record specifies the IP address corresponding to the domain name, and the NS record specifies which server resolves the domain name. MX record is a mail exchange record, pointing to the mail server. CNAME is an alias record.
Generally, by building a webserver, the IP of the website service can be written into the domain name A record, and the website uses port 80 or 443. Similarly, the mail service is port 25, port 1 10, which can be resolved by MX records of domain names.