Under most state and local laws, landlords must offer and maintain housing that satisfies basic habitability requirements, such as adequate weatherproofing, available heat, water, and electricity, and clean, sanitary, and structurally safe premises.
Local building or housing codes typically set specific standards, such as the minimum requirements for light, ventilation, and electrical wiring. Many cities require the installation of smoke detectors in residential units and specify security measures involving locks and keys. Your local building or housing authority and health or fire department, can provide information on local housing codes and penalties for violations.
Tenants have the responsibility to keep their own living quarters clean and sanitary. If you do not, you can't go to the landlord and request repairs that are due to your negligence, such as infestations of pests such as ants. In that case, the landlord could have the work done and send the repair bill to you.
When the landlord is responsible for making certain repairs, the landlord can usually delegate the repair tasks to the tenant in exchange for a reduction in rent (if the tenant agrees). If the tenant fails to do the job well, however, the landlord is not excused from his responsibility to maintain the property in a habitable condition. To learn more about the landlord's responsibility for keeping the unit in good repair, see Nolo's article Renters' Right to Minor Repairs. To learn more about your rights as a tenant, see Nolo's Renters' Rights & Tenants' Rights section.