A detailed video guide about underwater bases can be found here.
There are several basic techniques that are used and combined for underwater work. The most immediate issue is not drowning while you work, followed by clearing the water out of your new base. If your base is deep, getting there and back may also require special measures.
Armor with the Respiration enchantment can extend your breathing time underwater, but even so, for extended work, you will need to create an air bubble to which you can retreat to refill your breath meter. An alternative is to build your home in creative mode in which you cannot drown, and enter it using a tunnel that starts on dry land, stretches under the sand, and enters your underwater home. This option is great for beginners who want to build an underwater home but cannot make advanced potions or easily obtain the helmet.
There are many partial blocks which don't occupy all (or very much) of their space, but which can force water out of their entire block cell. Fences are probably the cheapest of the lot; if you stack two fences on the sea/lake bottom, you can stand next to them to breathe freely. (You need two so one will be at head height, but if you like, you can then mine the bottom one.) Cobblestone walls work exactly the same way, while glass panes and iron bars can provide extra breathing space and be connected for aesthetics. Many of these blocks will not work with the 1.13 update, however.
Several other blocks can also be used, but unlike fence-type blocks, these will break and drop if the block they were attached to goes away. A door is slightly awkward, but if you use a door, you will only have to place one thing to get your air pocket. However, if you have a vertical surface or block available, you can easily put a sign, ladder, trapdoor, or any of the above blocks against it at head height. You could stack two signs on the floor like the fences, but stacking signs is a bit specific, which is the last thing you want when your air is running out. However, you can also stick two signs on top of each other for a full block of air.
All of the above can also be used to block water out of entrances/exits which are generally a good place to start building. To make an air/water doorway from fences, glass panes, or iron bars, pick a corner of your underwater home, and place the fences or panes as though you were making a 2-block high corner window, but skip the actual corner. The two diagonal blocks will keep the water out, but you can easily walk between them.
Advanced players may have access to potions of Water Breathing, which will allow them to stay underwater for long times. However, it's still wise to have some air-pocket-making blocks handy just in case you run out air and/or potions.
In relatively shallow waters, you may be able to just swim down and place a "bubble block" as above. If your target spot is deep enough that getting there is risky, you can make a pillar of fences, glass, etc. from the bottom to shorten the trip. In SMP, you may need to have your pillar stop short of the surface, for concealment. If this is not an issue, the pillar can go all the way to the surface. If you want to go deep enough that you just can't swim down there, your best bet is probably to drop gravel or sand to make a starter pillar. Then you can run ladders down it from the surface, for initial access. However, you don't want to depend on this setup for long, because if any of the blocks are broken or moved, all the ladders above the break will drop. To make the pillar permanent, dig down, replacing the sand/gravel with bubble blocks as you go. You can even replace it with cobblestone or dirt, and then stick ladders on that. Alternatively, you can go down to the bottom, and make a new pillar somewhere else, or arrange for other means of access.
Lily pads can help with placing the gravel, or let you run a fence or glass pillar from the surface downward. To use this method, put one block on the pad, then use the side of that to place other blocks. Alternatively, an empty bucket can be used to create a short lived air pocket, refilling your breath meter. This can be enough to get you to the bottom of the ocean, without leaving any evidence that you've been there. It is safer to have at least two buckets if you intend to do this.
The simplest sort of underwater base is made by simply placing a door against an underwater mound. You may need at least a 3x3 space of dirt or stone to start with, and a floor block to put the door on). Once you open the door and step into it, you can simply continue to dig out a lair as if you were above ground. Once you have an entrance passage, you can place ladders or signs (or another door) inside the original door for a flush entrance, and remove the starter door. If you like, you can then turn around and clear out some of the water to continue your base outward.
For an even more inconspicuous entrance, you can start digging a 1x1 shaft down until you hit stone, or a little more, placing ladders every space as you go. Watch out for caves—if you break into one, you can either switch to securing the cave and use that for your base, or go back up, seal the hole, and dig somewhere else. Once you hit stone, mine the first two blocks down, then come back up and start digging horizontally. (This will divert water coming down the hole away from your horizontal passage.) Continue to hollow out your base until you're content.
Clearing Out Water
If you instead want your base to be truly "underwater", you will need to clear water out of a fairly large volume. One way to do this is to fill the space with blocks, and then remove most of them. So, construct rooms with walls and ceiling, but fill the inside with your chosen filler block. You can use an easy-to-break block such as dirt, wool, sand, or gravel. One of the best blocks is slime blocks or TNT as the can be insta-mined using just a fist, and can be broken even when you are fatigued by a Elder Guardian. Alternatively, you can use a flammable block as filler, such as wood planks or wool. Leaf blocks burn fastest, but there may be extra cleanup involved since fire does not burn evenly. Place jack o'lanterns, glowstone, or sea lanterns to light the new space, to prevent spawning. These are better alternatives to torches, since they will be washed away if water ever comes in.
Alternatively, you can choose to use sponges. This is the fastest way in creative mode. In survival, however, it may be more time/resource efficient to use the previously mentioned methods. For larger spaces you may need to partition the space into smaller areas, using walls or pillars of some other block to prevent the water from re-creating source water blocks. Sand or gravel can be dropped from construction platforms above, or you can use slime block,s as you can quickly punch the block with your fist, letting you make new pillars further into the large space, clearing out the water as you go. When a sponge is placed, it will soak up water in a 9x9x9 area centered on itself, and then turn wet and become unable to soak up any more water. Smelting it in a furnace will make it usable again.
If you have a completely flat and gigantic area, you may find it easier to build a MOSES machine, or other machine to clear the water for you.
This method is particularly good for building in very deep areas of water as it requires less time spent underwater.
Find a fairly deep patch (depending on how big you want your home to be) of water with a relatively flat floor. Then, on or above the water surface, build a platform out of any non-gravity block (it's best to use blocks you can remove easily—dirt, wool, leaves, etc.). Build the shape of your desired building on the platform out of gravel or sand, as a solid block or "sand castle", but without the exterior walls. When you are happy with your work, dig or burn out the platform underneath (beware of falling sand!). Then all you have to do underwater is cover the fallen mold with walls and ceiling, and hollow it out. A tip for hollowing: Bring down a slab or stair of any kind. Use it to dig out the bottom block of sand and immediately place it on the bottom of the space beneath. This may take a couple of tries, but when you get it in, the rest of the sand will fall on it and break.
SMP Hiding your Base
When in multiplayer, you may want to hide your ocean base so that other players won't find it. To do this, make your underwater home as deep as possible; if possible, on the bottom of a deep ocean with a central hub made of blue glass, or a gravel "hill" with a blue glass tower. Make sure half slabs are used over any kind of light near windows or exits. Farms should be lit, but make sure there is no hint of light coming out anywhere. Keep buildings separate, small, and blending in irregular shapes. Blue glass is the only glass that should be used as it blends in the best with water. The best thing about bases underwater is you can, if carefully planned, mold entire buildings.
Keep player detection systems stationed in a ring around 40 blocks away from where members should be. However, the best test is going up to the surface and drinking a potion of Night Vision. After looking at where your base is located to look for any obvious signs of a base, judge what else needs to be done to cover up your tracks. Then, fix what needs fixing under the effects of the potion.
- Sugar cane blocks water, but not movement. You can use them as air-to-water doors. However, placement is restricted: Just like on dry land, the bottom block must be placed on sand or dirt, with a water block next to, and one level below, the placed cane. Also, sugar cane is fragile, and if any cane is broken, all the canes above it will break too.
- Ice may form over the surface of your chosen water, especially in colder biomes. Make sure to arrange a way to get past it safely.
- Buckets can be used to regain your breath. If you need air, you can click an empty bucket anywhere (no target needed) to refill your air meter. However, that will fill the bucket. To empty the bucket so you can do that again, you need to click it on a block. Note that when using the empty bucket, make sure your head is in a water source block. In an ocean or in a river, however, all water blocks are source blocks, so this usually won't be important.
- Torches can be used for temporary air pockets—they will drop almost immediately, but if you're in their space, they will replenish your air meter.
- If building an underwater tunnel to access your base, remember that still water will allow you to pass in both directions at the same rate, but flowing water works better for one-way paths.
- You should always make a second door along with a chamber just in case one door breaks and your house is flooded.